{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "a33027b0-87f5-4879-b105-8c09980098e2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple\n",
      "Requirement already satisfied: polars in f:\\python\\conda\\envs\\week08\\lib\\site-packages (1.29.0)\n"
     ]
    }
   ],
   "source": [
    "!pip install polars"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "c41737b8-be46-4732-b045-93c5d7bcc9c5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "F:\\python\\conda\\envs\\week08\\python.exe\n"
     ]
    }
   ],
   "source": [
    "import sys\n",
    "\n",
    "print(sys.executable)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "5dd4f79b-1ef8-4a2d-bb60-ee9fae4356b3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple\n",
      "Requirement already satisfied: polars in f:\\python\\conda\\envs\\week08\\lib\\site-packages (1.29.0)\n",
      "Note: you may need to restart the kernel to use updated packages.\n"
     ]
    }
   ],
   "source": [
    "pip install polars"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "11589c4d-9d26-4555-a273-d79a097e6155",
   "metadata": {},
   "outputs": [],
   "source": [
    "import polars as pl"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "068ea052-3d72-4c96-9e97-3f6cb45f1515",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pl.read_csv(\"stock_trades/202207-湘财.xls\", encoding=\"gb18030\", separator=\"\\t\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "a9295ca4-85c2-481d-9aa2-05ce5649e4f2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "polars.dataframe.frame.DataFrame"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "62e23d30-bb73-4cad-a176-ff3960a702e1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(17, 16)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "2c13100a-537b-42d8-bdfc-42c5e9d1a152",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "17"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.height"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "ac1d9e9f-a054-4321-b390-2724faacbea1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Schema([('发生日期', Int64),\n",
       "        ('证券代码', String),\n",
       "        ('证券名称', String),\n",
       "        ('买卖标志', String),\n",
       "        ('业务名称', String),\n",
       "        ('成交时间', String),\n",
       "        ('成交数量', String),\n",
       "        ('成交价格', Float64),\n",
       "        ('成交金额', Float64),\n",
       "        ('发生金额', Float64),\n",
       "        ('手续费', String),\n",
       "        ('印花税', String),\n",
       "        ('过户费', String),\n",
       "        ('其他费', String),\n",
       "        ('备注', String),\n",
       "        ('币种', String)])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.schema"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "4ca4b8ae-07f7-4712-927f-120a850236bc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (17, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>20220721</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;卖出&quot;</td><td>&quot;股息入账&quot;</td><td>&quot;16:00:00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>3.6</td><td>4884.0</td><td>4884.0</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;股息入账:赣粤高速600269; 权益股数:40700;&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:03:27&quot;</td><td>&quot;-580.00&quot;</td><td>1.675</td><td>58000.0</td><td>58018.63</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:18.63实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;=&quot;002462&quot;&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;09:38:10&quot;</td><td>&quot;-10400.00&quot;</td><td>13.2062</td><td>137344.0</td><td>137184.67</td><td>&quot;21.98&quot;</td><td>&quot;137.35&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:52&quot;</td><td>&quot;47000.00&quot;</td><td>3.19</td><td>149930.0</td><td>-149955.5</td><td>&quot;23.99&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.51&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:31&quot;</td><td>&quot;11900.00&quot;</td><td>12.6066</td><td>150019.0</td><td>-150044.49</td><td>&quot;24.00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.49&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>20220711</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;质押回购拆出&quot;</td><td>&quot;09:39:27&quot;</td><td>&quot;580.00&quot;</td><td>1.675</td><td>58000.0</td><td>-58002.9</td><td>&quot;2.90&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券回购购回日:20220718预计利息:18.63参考占款…</td><td>&quot;人民币&quot;</td></tr><tr><td>20220711</td><td>&quot;601992&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:37:25&quot;</td><td>&quot;54000.00&quot;</td><td>2.59</td><td>139860.0</td><td>-139883.8</td><td>&quot;22.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.42&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220711</td><td>&quot;600894&quot;</td><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:36:30&quot;</td><td>&quot;21400.00&quot;</td><td>6.54</td><td>139956.0</td><td>-139979.8</td><td>&quot;22.39&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.41&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220711</td><td>&quot;601077&quot;</td><td>&quot;渝农商行&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:34:24&quot;</td><td>&quot;38300.00&quot;</td><td>3.65</td><td>139795.0</td><td>-139818.75</td><td>&quot;22.37&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220707</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:17:51&quot;</td><td>&quot;-7580.00&quot;</td><td>2.46</td><td>758000.0</td><td>758357.61</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:357.61实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (17, 16)\n",
       "┌──────────┬───────────┬──────────┬──────────┬───┬─────────┬─────────┬─────────────────────────────────┬────────┐\n",
       "│ 发生日期 ┆ 证券代码  ┆ 证券名称 ┆ 买卖标志 ┆ … ┆ 过户费  ┆ 其他费  ┆ 备注                            ┆ 币种   │\n",
       "│ ---      ┆ ---       ┆ ---      ┆ ---      ┆   ┆ ---     ┆ ---     ┆ ---                             ┆ ---    │\n",
       "│ i64      ┆ str       ┆ str      ┆ str      ┆   ┆ str     ┆ str     ┆ str                             ┆ str    │\n",
       "╞══════════╪═══════════╪══════════╪══════════╪═══╪═════════╪═════════╪═════════════════════════════════╪════════╡\n",
       "│ 20220721 ┆ 600269    ┆ 赣粤高速 ┆ 卖出     ┆ … ┆ =\"0.00\" ┆ =\"0.00\" ┆ 股息入账:赣粤高速600269;        ┆ 人民币 │\n",
       "│          ┆           ┆          ┆          ┆   ┆         ┆         ┆ 权益股数:40700;                 ┆        │\n",
       "│ 20220718 ┆ 204007    ┆ GC007    ┆ 卖出     ┆ … ┆ =\"0.00\" ┆ =\"0.00\" ┆ 融券购回:18.63实际占款天数：7-8 ┆ 人民币 │\n",
       "│          ┆           ┆          ┆          ┆   ┆         ┆         ┆ 88880                           ┆        │\n",
       "│ 20220718 ┆ =\"002462\" ┆ 嘉事堂   ┆ 卖出     ┆ … ┆ 1.38    ┆ =\"0.00\" ┆ 证券卖出                        ┆ 人民币 │\n",
       "│ 20220718 ┆ 600408    ┆ 安泰集团 ┆ 买入     ┆ … ┆ 1.51    ┆ =\"0.00\" ┆ 证券买入                        ┆ 人民币 │\n",
       "│ 20220718 ┆ 600648    ┆ 外高桥   ┆ 买入     ┆ … ┆ 1.49    ┆ =\"0.00\" ┆ 证券买入                        ┆ 人民币 │\n",
       "│ …        ┆ …         ┆ …        ┆ …        ┆ … ┆ …       ┆ …       ┆ …                               ┆ …      │\n",
       "│ 20220711 ┆ 204007    ┆ GC007    ┆ 卖出     ┆ … ┆ =\"0.00\" ┆ =\"0.00\" ┆ 融券回购购回日:20220718预计利息 ┆ 人民币 │\n",
       "│          ┆           ┆          ┆          ┆   ┆         ┆         ┆ :18.63参考占款…                 ┆        │\n",
       "│ 20220711 ┆ 601992    ┆ 金隅集团 ┆ 买入     ┆ … ┆ 1.42    ┆ =\"0.00\" ┆ 证券买入                        ┆ 人民币 │\n",
       "│ 20220711 ┆ 600894    ┆ 广日股份 ┆ 买入     ┆ … ┆ 1.41    ┆ =\"0.00\" ┆ 证券买入                        ┆ 人民币 │\n",
       "│ 20220711 ┆ 601077    ┆ 渝农商行 ┆ 买入     ┆ … ┆ 1.38    ┆ =\"0.00\" ┆ 证券买入                        ┆ 人民币 │\n",
       "│ 20220707 ┆ 204007    ┆ GC007    ┆ 卖出     ┆ … ┆ =\"0.00\" ┆ =\"0.00\" ┆ 融券购回:357.61实际占款天数：7- ┆ 人民币 │\n",
       "│          ┆           ┆          ┆          ┆   ┆         ┆         ┆ 888880                          ┆        │\n",
       "└──────────┴───────────┴──────────┴──────────┴───┴─────────┴─────────┴─────────────────────────────────┴────────┘"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "b7e5bc1e-4740-4044-8cca-9d59a6cde349",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (1, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>20220721</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;卖出&quot;</td><td>&quot;股息入账&quot;</td><td>&quot;16:00:00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>3.6</td><td>4884.0</td><td>4884.0</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;股息入账:赣粤高速600269; 权益股数:40700;&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (1, 16)\n",
       "┌──────────┬──────────┬──────────┬──────────┬───┬─────────┬─────────┬─────────────────────────────────┬────────┐\n",
       "│ 发生日期 ┆ 证券代码 ┆ 证券名称 ┆ 买卖标志 ┆ … ┆ 过户费  ┆ 其他费  ┆ 备注                            ┆ 币种   │\n",
       "│ ---      ┆ ---      ┆ ---      ┆ ---      ┆   ┆ ---     ┆ ---     ┆ ---                             ┆ ---    │\n",
       "│ i64      ┆ str      ┆ str      ┆ str      ┆   ┆ str     ┆ str     ┆ str                             ┆ str    │\n",
       "╞══════════╪══════════╪══════════╪══════════╪═══╪═════════╪═════════╪═════════════════════════════════╪════════╡\n",
       "│ 20220721 ┆ 600269   ┆ 赣粤高速 ┆ 卖出     ┆ … ┆ =\"0.00\" ┆ =\"0.00\" ┆ 股息入账:赣粤高速600269;        ┆ 人民币 │\n",
       "│          ┆          ┆          ┆          ┆   ┆         ┆         ┆ 权益股数:40700;                 ┆        │\n",
       "└──────────┴──────────┴──────────┴──────────┴───┴─────────┴─────────┴─────────────────────────────────┴────────┘"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "c4e8ea15-5f58-4a4b-9c78-7575bca81cf7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (2, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>20220718</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:52&quot;</td><td>&quot;47000.00&quot;</td><td>3.19</td><td>149930.0</td><td>-149955.5</td><td>&quot;23.99&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.51&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:31&quot;</td><td>&quot;11900.00&quot;</td><td>12.6066</td><td>150019.0</td><td>-150044.49</td><td>&quot;24.00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.49&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (2, 16)\n",
       "┌──────────┬──────────┬──────────┬──────────┬───┬────────┬─────────┬──────────┬────────┐\n",
       "│ 发生日期 ┆ 证券代码 ┆ 证券名称 ┆ 买卖标志 ┆ … ┆ 过户费 ┆ 其他费  ┆ 备注     ┆ 币种   │\n",
       "│ ---      ┆ ---      ┆ ---      ┆ ---      ┆   ┆ ---    ┆ ---     ┆ ---      ┆ ---    │\n",
       "│ i64      ┆ str      ┆ str      ┆ str      ┆   ┆ str    ┆ str     ┆ str      ┆ str    │\n",
       "╞══════════╪══════════╪══════════╪══════════╪═══╪════════╪═════════╪══════════╪════════╡\n",
       "│ 20220718 ┆ 600408   ┆ 安泰集团 ┆ 买入     ┆ … ┆ 1.51   ┆ =\"0.00\" ┆ 证券买入 ┆ 人民币 │\n",
       "│ 20220718 ┆ 600648   ┆ 外高桥   ┆ 买入     ┆ … ┆ 1.49   ┆ =\"0.00\" ┆ 证券买入 ┆ 人民币 │\n",
       "└──────────┴──────────┴──────────┴──────────┴───┴────────┴─────────┴──────────┴────────┘"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[3:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "d4aa284c-e501-4006-a16f-635a4940a53b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (2, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>20220718</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:52&quot;</td><td>&quot;47000.00&quot;</td><td>3.19</td><td>149930.0</td><td>-149955.5</td><td>&quot;23.99&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.51&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:31&quot;</td><td>&quot;11900.00&quot;</td><td>12.6066</td><td>150019.0</td><td>-150044.49</td><td>&quot;24.00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.49&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (2, 16)\n",
       "┌──────────┬──────────┬──────────┬──────────┬───┬────────┬─────────┬──────────┬────────┐\n",
       "│ 发生日期 ┆ 证券代码 ┆ 证券名称 ┆ 买卖标志 ┆ … ┆ 过户费 ┆ 其他费  ┆ 备注     ┆ 币种   │\n",
       "│ ---      ┆ ---      ┆ ---      ┆ ---      ┆   ┆ ---    ┆ ---     ┆ ---      ┆ ---    │\n",
       "│ i64      ┆ str      ┆ str      ┆ str      ┆   ┆ str    ┆ str     ┆ str      ┆ str    │\n",
       "╞══════════╪══════════╪══════════╪══════════╪═══╪════════╪═════════╪══════════╪════════╡\n",
       "│ 20220718 ┆ 600408   ┆ 安泰集团 ┆ 买入     ┆ … ┆ 1.51   ┆ =\"0.00\" ┆ 证券买入 ┆ 人民币 │\n",
       "│ 20220718 ┆ 600648   ┆ 外高桥   ┆ 买入     ┆ … ┆ 1.49   ┆ =\"0.00\" ┆ 证券买入 ┆ 人民币 │\n",
       "└──────────┴──────────┴──────────┴──────────┴───┴────────┴─────────┴──────────┴────────┘"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[3:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "591922ba-4f6f-4a4c-915d-60519912bc6f",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (2414318617.py, line 1)",
     "output_type": "error",
     "traceback": [
      "  \u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[14]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[31m    \u001b[39m\u001b[31mdf[,0]\u001b[39m\n       ^\n\u001b[31mSyntaxError\u001b[39m\u001b[31m:\u001b[39m invalid syntax\n"
     ]
    }
   ],
   "source": [
    "df[,0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "ada21d72-7361-4f20-9319-d09d276746bd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (17,)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th></tr><tr><td>i64</td></tr></thead><tbody><tr><td>20220721</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr><tr><td>&hellip;</td></tr><tr><td>20220711</td></tr><tr><td>20220711</td></tr><tr><td>20220711</td></tr><tr><td>20220711</td></tr><tr><td>20220707</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (17,)\n",
       "Series: '发生日期' [i64]\n",
       "[\n",
       "\t20220721\n",
       "\t20220718\n",
       "\t20220718\n",
       "\t20220718\n",
       "\t20220718\n",
       "\t…\n",
       "\t20220711\n",
       "\t20220711\n",
       "\t20220711\n",
       "\t20220711\n",
       "\t20220707\n",
       "]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[:, 0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "368d66cb-f4e0-4035-accc-eef71540a538",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (17, 2)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券名称</th><th>成交金额</th></tr><tr><td>str</td><td>f64</td></tr></thead><tbody><tr><td>&quot;赣粤高速&quot;</td><td>4884.0</td></tr><tr><td>&quot;GC007&quot;</td><td>58000.0</td></tr><tr><td>&quot;嘉事堂&quot;</td><td>137344.0</td></tr><tr><td>&quot;安泰集团&quot;</td><td>149930.0</td></tr><tr><td>&quot;外高桥&quot;</td><td>150019.0</td></tr><tr><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;GC007&quot;</td><td>58000.0</td></tr><tr><td>&quot;金隅集团&quot;</td><td>139860.0</td></tr><tr><td>&quot;广日股份&quot;</td><td>139956.0</td></tr><tr><td>&quot;渝农商行&quot;</td><td>139795.0</td></tr><tr><td>&quot;GC007&quot;</td><td>758000.0</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (17, 2)\n",
       "┌──────────┬──────────┐\n",
       "│ 证券名称 ┆ 成交金额 │\n",
       "│ ---      ┆ ---      │\n",
       "│ str      ┆ f64      │\n",
       "╞══════════╪══════════╡\n",
       "│ 赣粤高速 ┆ 4884.0   │\n",
       "│ GC007    ┆ 58000.0  │\n",
       "│ 嘉事堂   ┆ 137344.0 │\n",
       "│ 安泰集团 ┆ 149930.0 │\n",
       "│ 外高桥   ┆ 150019.0 │\n",
       "│ …        ┆ …        │\n",
       "│ GC007    ┆ 58000.0  │\n",
       "│ 金隅集团 ┆ 139860.0 │\n",
       "│ 广日股份 ┆ 139956.0 │\n",
       "│ 渝农商行 ┆ 139795.0 │\n",
       "│ GC007    ┆ 758000.0 │\n",
       "└──────────┴──────────┘"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[:, [\"证券名称\", \"成交金额\"]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "23686b56-9934-4d79-bdc3-83c81f22817e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(20220721,\n",
       " '600269',\n",
       " '赣粤高速',\n",
       " '卖出',\n",
       " '股息入账',\n",
       " '16:00:00',\n",
       " '=\"0.00\"',\n",
       " 3.6,\n",
       " 4884.0,\n",
       " 4884.0,\n",
       " '=\"0.00\"',\n",
       " '=\"0.00\"',\n",
       " '=\"0.00\"',\n",
       " '=\"0.00\"',\n",
       " '股息入账:赣粤高速600269; 权益股数:40700;',\n",
       " '人民币')"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.row(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "2cb9959a-81fb-4f1a-b2cb-fb9475657e79",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Rows: 17\n",
      "Columns: 16\n",
      "$ 发生日期 <i64> 20220721, 20220718, 20220718, 20220718, 20220718, 20220718, 20220718, 20220718, 20220718, 20220718\n",
      "$ 证券代码 <str> '600269', '204007', '=\"002462\"', '600408', '600648', '600269', '600015', '601992', '600894', '601077'\n",
      "$ 证券名称 <str> '赣粤高速', 'GC007', '嘉事堂', '安泰集团', '外高桥', '赣粤高速', '华夏银行', '金隅集团', '广日股份', '渝农商行'\n",
      "$ 买卖标志 <str> '卖出', '卖出', '卖出', '买入', '买入', '买入', '买入', '卖出', '卖出', '卖出'\n",
      "$ 业务名称 <str> '股息入账', '拆出质押购回', '证券卖出', '证券买入', '证券买入', '证券买入', '证券买入', '证券卖出', '证券卖出', '证券卖出'\n",
      "$ 成交时间 <str> '16:00:00', '19:03:27', '09:38:10', '09:44:52', '09:44:31', '09:43:38', '09:42:51', '09:39:28', '09:39:06', '09:38:30'\n",
      "$ 成交数量 <str> '=\"0.00\"', '-580.00', '-10400.00', '47000.00', '11900.00', '40700.00', '30000.00', '-54000.00', '-21400.00', '-38300.00'\n",
      "$ 成交价格 <f64> 3.6, 1.675, 13.2062, 3.19, 12.6066, 3.69, 5.07, 2.5683, 6.5419, 3.58\n",
      "$ 成交金额 <f64> 4884.0, 58000.0, 137344.0, 149930.0, 150019.0, 150183.0, 152100.0, 138686.0, 139996.0, 137114.0\n",
      "$ 发生金额 <f64> 4884.0, 58018.63, 137184.67, -149955.5, -150044.49, -150208.53, -152125.86, 138523.74, 139832.12, 136953.55\n",
      "$ 手续费  <str> '=\"0.00\"', '=\"0.00\"', '21.98', '23.99', '24.00', '24.03', '24.34', '22.19', '22.40', '21.94'\n",
      "$ 印花税  <str> '=\"0.00\"', '=\"0.00\"', '137.35', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '138.69', '140.02', '137.13'\n",
      "$ 过户费  <str> '=\"0.00\"', '=\"0.00\"', '1.38', '1.51', '1.49', '1.50', '1.52', '1.38', '1.46', '1.38'\n",
      "$ 其他费  <str> '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"'\n",
      "$ 备注   <str> '股息入账:赣粤高速600269; 权益股数:40700;', '融券购回:18.63实际占款天数：7-888880', '证券卖出', '证券买入', '证券买入', '证券买入', '证券买入', '证券卖出', '证券卖出', '证券卖出'\n",
      "$ 币种   <str> '人民币', '人民币', '人民币', '人民币', '人民币', '人民币', '人民币', '人民币', '人民币', '人民币'\n",
      "\n"
     ]
    }
   ],
   "source": [
    "df.glimpse()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "2be0ede4-247d-4801-8cbc-1e1c4990375b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (5, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>20220721</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;卖出&quot;</td><td>&quot;股息入账&quot;</td><td>&quot;16:00:00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>3.6</td><td>4884.0</td><td>4884.0</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;股息入账:赣粤高速600269; 权益股数:40700;&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:03:27&quot;</td><td>&quot;-580.00&quot;</td><td>1.675</td><td>58000.0</td><td>58018.63</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:18.63实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;=&quot;002462&quot;&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;09:38:10&quot;</td><td>&quot;-10400.00&quot;</td><td>13.2062</td><td>137344.0</td><td>137184.67</td><td>&quot;21.98&quot;</td><td>&quot;137.35&quot;</td><td>&quot;1.38&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:52&quot;</td><td>&quot;47000.00&quot;</td><td>3.19</td><td>149930.0</td><td>-149955.5</td><td>&quot;23.99&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.51&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr><tr><td>20220718</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:31&quot;</td><td>&quot;11900.00&quot;</td><td>12.6066</td><td>150019.0</td><td>-150044.49</td><td>&quot;24.00&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;1.49&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (5, 16)\n",
       "┌──────────┬───────────┬──────────┬──────────┬───┬─────────┬─────────┬─────────────────────────────────┬────────┐\n",
       "│ 发生日期 ┆ 证券代码  ┆ 证券名称 ┆ 买卖标志 ┆ … ┆ 过户费  ┆ 其他费  ┆ 备注                            ┆ 币种   │\n",
       "│ ---      ┆ ---       ┆ ---      ┆ ---      ┆   ┆ ---     ┆ ---     ┆ ---                             ┆ ---    │\n",
       "│ i64      ┆ str       ┆ str      ┆ str      ┆   ┆ str     ┆ str     ┆ str                             ┆ str    │\n",
       "╞══════════╪═══════════╪══════════╪══════════╪═══╪═════════╪═════════╪═════════════════════════════════╪════════╡\n",
       "│ 20220721 ┆ 600269    ┆ 赣粤高速 ┆ 卖出     ┆ … ┆ =\"0.00\" ┆ =\"0.00\" ┆ 股息入账:赣粤高速600269;        ┆ 人民币 │\n",
       "│          ┆           ┆          ┆          ┆   ┆         ┆         ┆ 权益股数:40700;                 ┆        │\n",
       "│ 20220718 ┆ 204007    ┆ GC007    ┆ 卖出     ┆ … ┆ =\"0.00\" ┆ =\"0.00\" ┆ 融券购回:18.63实际占款天数：7-8 ┆ 人民币 │\n",
       "│          ┆           ┆          ┆          ┆   ┆         ┆         ┆ 88880                           ┆        │\n",
       "│ 20220718 ┆ =\"002462\" ┆ 嘉事堂   ┆ 卖出     ┆ … ┆ 1.38    ┆ =\"0.00\" ┆ 证券卖出                        ┆ 人民币 │\n",
       "│ 20220718 ┆ 600408    ┆ 安泰集团 ┆ 买入     ┆ … ┆ 1.51    ┆ =\"0.00\" ┆ 证券买入                        ┆ 人民币 │\n",
       "│ 20220718 ┆ 600648    ┆ 外高桥   ┆ 买入     ┆ … ┆ 1.49    ┆ =\"0.00\" ┆ 证券买入                        ┆ 人民币 │\n",
       "└──────────┴───────────┴──────────┴──────────┴───┴─────────┴─────────┴─────────────────────────────────┴────────┘"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "82745789-3a18-4465-af12-3e73dab4158f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (1, 16)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th></tr><tr><td>i64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>20220707</td><td>&quot;204007&quot;</td><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:17:51&quot;</td><td>&quot;-7580.00&quot;</td><td>2.46</td><td>758000.0</td><td>758357.61</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;=&quot;0.00&quot;&quot;</td><td>&quot;融券购回:357.61实际占款天数：7-888880&quot;</td><td>&quot;人民币&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (1, 16)\n",
       "┌──────────┬──────────┬──────────┬──────────┬───┬─────────┬─────────┬─────────────────────────────────┬────────┐\n",
       "│ 发生日期 ┆ 证券代码 ┆ 证券名称 ┆ 买卖标志 ┆ … ┆ 过户费  ┆ 其他费  ┆ 备注                            ┆ 币种   │\n",
       "│ ---      ┆ ---      ┆ ---      ┆ ---      ┆   ┆ ---     ┆ ---     ┆ ---                             ┆ ---    │\n",
       "│ i64      ┆ str      ┆ str      ┆ str      ┆   ┆ str     ┆ str     ┆ str                             ┆ str    │\n",
       "╞══════════╪══════════╪══════════╪══════════╪═══╪═════════╪═════════╪═════════════════════════════════╪════════╡\n",
       "│ 20220707 ┆ 204007   ┆ GC007    ┆ 卖出     ┆ … ┆ =\"0.00\" ┆ =\"0.00\" ┆ 融券购回:357.61实际占款天数：7- ┆ 人民币 │\n",
       "│          ┆          ┆          ┆          ┆   ┆         ┆         ┆ 888880                          ┆        │\n",
       "└──────────┴──────────┴──────────┴──────────┴───┴─────────┴─────────┴─────────────────────────────────┴────────┘"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sample()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "449ed5c7-17e6-4d18-9643-fbf70c743de2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (5, 5)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th></tr><tr><td>str</td><td>str</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;广日股份&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:36:30&quot;</td><td>&quot;21400.00&quot;</td></tr><tr><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:44:52&quot;</td><td>&quot;47000.00&quot;</td></tr><tr><td>&quot;GC007&quot;</td><td>&quot;卖出&quot;</td><td>&quot;拆出质押购回&quot;</td><td>&quot;19:17:51&quot;</td><td>&quot;-7580.00&quot;</td></tr><tr><td>&quot;华夏银行&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:42:51&quot;</td><td>&quot;30000.00&quot;</td></tr><tr><td>&quot;赣粤高速&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>&quot;09:43:38&quot;</td><td>&quot;40700.00&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (5, 5)\n",
       "┌──────────┬──────────┬──────────────┬──────────┬──────────┐\n",
       "│ 证券名称 ┆ 买卖标志 ┆ 业务名称     ┆ 成交时间 ┆ 成交数量 │\n",
       "│ ---      ┆ ---      ┆ ---          ┆ ---      ┆ ---      │\n",
       "│ str      ┆ str      ┆ str          ┆ str      ┆ str      │\n",
       "╞══════════╪══════════╪══════════════╪══════════╪══════════╡\n",
       "│ 广日股份 ┆ 买入     ┆ 证券买入     ┆ 09:36:30 ┆ 21400.00 │\n",
       "│ 安泰集团 ┆ 买入     ┆ 证券买入     ┆ 09:44:52 ┆ 47000.00 │\n",
       "│ GC007    ┆ 卖出     ┆ 拆出质押购回 ┆ 19:17:51 ┆ -7580.00 │\n",
       "│ 华夏银行 ┆ 买入     ┆ 证券买入     ┆ 09:42:51 ┆ 30000.00 │\n",
       "│ 赣粤高速 ┆ 买入     ┆ 证券买入     ┆ 09:43:38 ┆ 40700.00 │\n",
       "└──────────┴──────────┴──────────────┴──────────┴──────────┘"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[:, \"证券名称\":\"成交数量\"].sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "eef2377e-135b-4330-a1ed-5ddaa952054e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<bound method DataFrame.describe of shape: (17, 16)\n",
       "┌──────────┬───────────┬──────────┬──────────┬───┬─────────┬─────────┬─────────────────────────────────┬────────┐\n",
       "│ 发生日期 ┆ 证券代码  ┆ 证券名称 ┆ 买卖标志 ┆ … ┆ 过户费  ┆ 其他费  ┆ 备注                            ┆ 币种   │\n",
       "│ ---      ┆ ---       ┆ ---      ┆ ---      ┆   ┆ ---     ┆ ---     ┆ ---                             ┆ ---    │\n",
       "│ i64      ┆ str       ┆ str      ┆ str      ┆   ┆ str     ┆ str     ┆ str                             ┆ str    │\n",
       "╞══════════╪═══════════╪══════════╪══════════╪═══╪═════════╪═════════╪═════════════════════════════════╪════════╡\n",
       "│ 20220721 ┆ 600269    ┆ 赣粤高速 ┆ 卖出     ┆ … ┆ =\"0.00\" ┆ =\"0.00\" ┆ 股息入账:赣粤高速600269;        ┆ 人民币 │\n",
       "│          ┆           ┆          ┆          ┆   ┆         ┆         ┆ 权益股数:40700;                 ┆        │\n",
       "│ 20220718 ┆ 204007    ┆ GC007    ┆ 卖出     ┆ … ┆ =\"0.00\" ┆ =\"0.00\" ┆ 融券购回:18.63实际占款天数：7-8 ┆ 人民币 │\n",
       "│          ┆           ┆          ┆          ┆   ┆         ┆         ┆ 88880                           ┆        │\n",
       "│ 20220718 ┆ =\"002462\" ┆ 嘉事堂   ┆ 卖出     ┆ … ┆ 1.38    ┆ =\"0.00\" ┆ 证券卖出                        ┆ 人民币 │\n",
       "│ 20220718 ┆ 600408    ┆ 安泰集团 ┆ 买入     ┆ … ┆ 1.51    ┆ =\"0.00\" ┆ 证券买入                        ┆ 人民币 │\n",
       "│ 20220718 ┆ 600648    ┆ 外高桥   ┆ 买入     ┆ … ┆ 1.49    ┆ =\"0.00\" ┆ 证券买入                        ┆ 人民币 │\n",
       "│ …        ┆ …         ┆ …        ┆ …        ┆ … ┆ …       ┆ …       ┆ …                               ┆ …      │\n",
       "│ 20220711 ┆ 204007    ┆ GC007    ┆ 卖出     ┆ … ┆ =\"0.00\" ┆ =\"0.00\" ┆ 融券回购购回日:20220718预计利息 ┆ 人民币 │\n",
       "│          ┆           ┆          ┆          ┆   ┆         ┆         ┆ :18.63参考占款…                 ┆        │\n",
       "│ 20220711 ┆ 601992    ┆ 金隅集团 ┆ 买入     ┆ … ┆ 1.42    ┆ =\"0.00\" ┆ 证券买入                        ┆ 人民币 │\n",
       "│ 20220711 ┆ 600894    ┆ 广日股份 ┆ 买入     ┆ … ┆ 1.41    ┆ =\"0.00\" ┆ 证券买入                        ┆ 人民币 │\n",
       "│ 20220711 ┆ 601077    ┆ 渝农商行 ┆ 买入     ┆ … ┆ 1.38    ┆ =\"0.00\" ┆ 证券买入                        ┆ 人民币 │\n",
       "│ 20220707 ┆ 204007    ┆ GC007    ┆ 卖出     ┆ … ┆ =\"0.00\" ┆ =\"0.00\" ┆ 融券购回:357.61实际占款天数：7- ┆ 人民币 │\n",
       "│          ┆           ┆          ┆          ┆   ┆         ┆         ┆ 888880                          ┆        │\n",
       "└──────────┴───────────┴──────────┴──────────┴───┴─────────┴─────────┴─────────────────────────────────┴────────┘>"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "429f7bc3-f67b-4384-a6d1-9d98d4a809c1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>发生日期</th>\n",
       "      <th>证券代码</th>\n",
       "      <th>证券名称</th>\n",
       "      <th>买卖标志</th>\n",
       "      <th>业务名称</th>\n",
       "      <th>成交时间</th>\n",
       "      <th>成交数量</th>\n",
       "      <th>成交价格</th>\n",
       "      <th>成交金额</th>\n",
       "      <th>发生金额</th>\n",
       "      <th>手续费</th>\n",
       "      <th>印花税</th>\n",
       "      <th>过户费</th>\n",
       "      <th>其他费</th>\n",
       "      <th>备注</th>\n",
       "      <th>币种</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>20220721</td>\n",
       "      <td>600269</td>\n",
       "      <td>赣粤高速</td>\n",
       "      <td>卖出</td>\n",
       "      <td>股息入账</td>\n",
       "      <td>16:00:00</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>3.6000</td>\n",
       "      <td>4884.0</td>\n",
       "      <td>4884.00</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>股息入账:赣粤高速600269; 权益股数:40700;</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>20220718</td>\n",
       "      <td>204007</td>\n",
       "      <td>GC007</td>\n",
       "      <td>卖出</td>\n",
       "      <td>拆出质押购回</td>\n",
       "      <td>19:03:27</td>\n",
       "      <td>-580.00</td>\n",
       "      <td>1.6750</td>\n",
       "      <td>58000.0</td>\n",
       "      <td>58018.63</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>融券购回:18.63实际占款天数：7-888880</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>20220718</td>\n",
       "      <td>=\"002462\"</td>\n",
       "      <td>嘉事堂</td>\n",
       "      <td>卖出</td>\n",
       "      <td>证券卖出</td>\n",
       "      <td>09:38:10</td>\n",
       "      <td>-10400.00</td>\n",
       "      <td>13.2062</td>\n",
       "      <td>137344.0</td>\n",
       "      <td>137184.67</td>\n",
       "      <td>21.98</td>\n",
       "      <td>137.35</td>\n",
       "      <td>1.38</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券卖出</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>20220718</td>\n",
       "      <td>600408</td>\n",
       "      <td>安泰集团</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:44:52</td>\n",
       "      <td>47000.00</td>\n",
       "      <td>3.1900</td>\n",
       "      <td>149930.0</td>\n",
       "      <td>-149955.50</td>\n",
       "      <td>23.99</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.51</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>20220718</td>\n",
       "      <td>600648</td>\n",
       "      <td>外高桥</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:44:31</td>\n",
       "      <td>11900.00</td>\n",
       "      <td>12.6066</td>\n",
       "      <td>150019.0</td>\n",
       "      <td>-150044.49</td>\n",
       "      <td>24.00</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.49</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>20220718</td>\n",
       "      <td>600269</td>\n",
       "      <td>赣粤高速</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:43:38</td>\n",
       "      <td>40700.00</td>\n",
       "      <td>3.6900</td>\n",
       "      <td>150183.0</td>\n",
       "      <td>-150208.53</td>\n",
       "      <td>24.03</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.50</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>20220718</td>\n",
       "      <td>600015</td>\n",
       "      <td>华夏银行</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:42:51</td>\n",
       "      <td>30000.00</td>\n",
       "      <td>5.0700</td>\n",
       "      <td>152100.0</td>\n",
       "      <td>-152125.86</td>\n",
       "      <td>24.34</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.52</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>20220718</td>\n",
       "      <td>601992</td>\n",
       "      <td>金隅集团</td>\n",
       "      <td>卖出</td>\n",
       "      <td>证券卖出</td>\n",
       "      <td>09:39:28</td>\n",
       "      <td>-54000.00</td>\n",
       "      <td>2.5683</td>\n",
       "      <td>138686.0</td>\n",
       "      <td>138523.74</td>\n",
       "      <td>22.19</td>\n",
       "      <td>138.69</td>\n",
       "      <td>1.38</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券卖出</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>20220718</td>\n",
       "      <td>600894</td>\n",
       "      <td>广日股份</td>\n",
       "      <td>卖出</td>\n",
       "      <td>证券卖出</td>\n",
       "      <td>09:39:06</td>\n",
       "      <td>-21400.00</td>\n",
       "      <td>6.5419</td>\n",
       "      <td>139996.0</td>\n",
       "      <td>139832.12</td>\n",
       "      <td>22.40</td>\n",
       "      <td>140.02</td>\n",
       "      <td>1.46</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券卖出</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>20220718</td>\n",
       "      <td>601077</td>\n",
       "      <td>渝农商行</td>\n",
       "      <td>卖出</td>\n",
       "      <td>证券卖出</td>\n",
       "      <td>09:38:30</td>\n",
       "      <td>-38300.00</td>\n",
       "      <td>3.5800</td>\n",
       "      <td>137114.0</td>\n",
       "      <td>136953.55</td>\n",
       "      <td>21.94</td>\n",
       "      <td>137.13</td>\n",
       "      <td>1.38</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券卖出</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>20220711</td>\n",
       "      <td>=\"002462\"</td>\n",
       "      <td>嘉事堂</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:38:16</td>\n",
       "      <td>10400.00</td>\n",
       "      <td>13.5100</td>\n",
       "      <td>140504.0</td>\n",
       "      <td>-140526.48</td>\n",
       "      <td>22.48</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.41</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>20220711</td>\n",
       "      <td>=\"000900\"</td>\n",
       "      <td>现代投资</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:33:37</td>\n",
       "      <td>34400.00</td>\n",
       "      <td>4.0500</td>\n",
       "      <td>139320.0</td>\n",
       "      <td>-139342.29</td>\n",
       "      <td>22.29</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.39</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>20220711</td>\n",
       "      <td>204007</td>\n",
       "      <td>GC007</td>\n",
       "      <td>卖出</td>\n",
       "      <td>质押回购拆出</td>\n",
       "      <td>09:39:27</td>\n",
       "      <td>580.00</td>\n",
       "      <td>1.6750</td>\n",
       "      <td>58000.0</td>\n",
       "      <td>-58002.90</td>\n",
       "      <td>2.90</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>融券回购购回日:20220718预计利息:18.63参考占款天数：7-888880</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>20220711</td>\n",
       "      <td>601992</td>\n",
       "      <td>金隅集团</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:37:25</td>\n",
       "      <td>54000.00</td>\n",
       "      <td>2.5900</td>\n",
       "      <td>139860.0</td>\n",
       "      <td>-139883.80</td>\n",
       "      <td>22.38</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.42</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>20220711</td>\n",
       "      <td>600894</td>\n",
       "      <td>广日股份</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:36:30</td>\n",
       "      <td>21400.00</td>\n",
       "      <td>6.5400</td>\n",
       "      <td>139956.0</td>\n",
       "      <td>-139979.80</td>\n",
       "      <td>22.39</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.41</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>20220711</td>\n",
       "      <td>601077</td>\n",
       "      <td>渝农商行</td>\n",
       "      <td>买入</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>09:34:24</td>\n",
       "      <td>38300.00</td>\n",
       "      <td>3.6500</td>\n",
       "      <td>139795.0</td>\n",
       "      <td>-139818.75</td>\n",
       "      <td>22.37</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>1.38</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>证券买入</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>20220707</td>\n",
       "      <td>204007</td>\n",
       "      <td>GC007</td>\n",
       "      <td>卖出</td>\n",
       "      <td>拆出质押购回</td>\n",
       "      <td>19:17:51</td>\n",
       "      <td>-7580.00</td>\n",
       "      <td>2.4600</td>\n",
       "      <td>758000.0</td>\n",
       "      <td>758357.61</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>=\"0.00\"</td>\n",
       "      <td>融券购回:357.61实际占款天数：7-888880</td>\n",
       "      <td>人民币</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        发生日期       证券代码   证券名称 买卖标志    业务名称      成交时间       成交数量     成交价格  \\\n",
       "0   20220721     600269   赣粤高速   卖出    股息入账  16:00:00    =\"0.00\"   3.6000   \n",
       "1   20220718     204007  GC007   卖出  拆出质押购回  19:03:27    -580.00   1.6750   \n",
       "2   20220718  =\"002462\"    嘉事堂   卖出    证券卖出  09:38:10  -10400.00  13.2062   \n",
       "3   20220718     600408   安泰集团   买入    证券买入  09:44:52   47000.00   3.1900   \n",
       "4   20220718     600648    外高桥   买入    证券买入  09:44:31   11900.00  12.6066   \n",
       "5   20220718     600269   赣粤高速   买入    证券买入  09:43:38   40700.00   3.6900   \n",
       "6   20220718     600015   华夏银行   买入    证券买入  09:42:51   30000.00   5.0700   \n",
       "7   20220718     601992   金隅集团   卖出    证券卖出  09:39:28  -54000.00   2.5683   \n",
       "8   20220718     600894   广日股份   卖出    证券卖出  09:39:06  -21400.00   6.5419   \n",
       "9   20220718     601077   渝农商行   卖出    证券卖出  09:38:30  -38300.00   3.5800   \n",
       "10  20220711  =\"002462\"    嘉事堂   买入    证券买入  09:38:16   10400.00  13.5100   \n",
       "11  20220711  =\"000900\"   现代投资   买入    证券买入  09:33:37   34400.00   4.0500   \n",
       "12  20220711     204007  GC007   卖出  质押回购拆出  09:39:27     580.00   1.6750   \n",
       "13  20220711     601992   金隅集团   买入    证券买入  09:37:25   54000.00   2.5900   \n",
       "14  20220711     600894   广日股份   买入    证券买入  09:36:30   21400.00   6.5400   \n",
       "15  20220711     601077   渝农商行   买入    证券买入  09:34:24   38300.00   3.6500   \n",
       "16  20220707     204007  GC007   卖出  拆出质押购回  19:17:51   -7580.00   2.4600   \n",
       "\n",
       "        成交金额       发生金额      手续费      印花税      过户费      其他费  \\\n",
       "0     4884.0    4884.00  =\"0.00\"  =\"0.00\"  =\"0.00\"  =\"0.00\"   \n",
       "1    58000.0   58018.63  =\"0.00\"  =\"0.00\"  =\"0.00\"  =\"0.00\"   \n",
       "2   137344.0  137184.67    21.98   137.35     1.38  =\"0.00\"   \n",
       "3   149930.0 -149955.50    23.99  =\"0.00\"     1.51  =\"0.00\"   \n",
       "4   150019.0 -150044.49    24.00  =\"0.00\"     1.49  =\"0.00\"   \n",
       "5   150183.0 -150208.53    24.03  =\"0.00\"     1.50  =\"0.00\"   \n",
       "6   152100.0 -152125.86    24.34  =\"0.00\"     1.52  =\"0.00\"   \n",
       "7   138686.0  138523.74    22.19   138.69     1.38  =\"0.00\"   \n",
       "8   139996.0  139832.12    22.40   140.02     1.46  =\"0.00\"   \n",
       "9   137114.0  136953.55    21.94   137.13     1.38  =\"0.00\"   \n",
       "10  140504.0 -140526.48    22.48  =\"0.00\"     1.41  =\"0.00\"   \n",
       "11  139320.0 -139342.29    22.29  =\"0.00\"     1.39  =\"0.00\"   \n",
       "12   58000.0  -58002.90     2.90  =\"0.00\"  =\"0.00\"  =\"0.00\"   \n",
       "13  139860.0 -139883.80    22.38  =\"0.00\"     1.42  =\"0.00\"   \n",
       "14  139956.0 -139979.80    22.39  =\"0.00\"     1.41  =\"0.00\"   \n",
       "15  139795.0 -139818.75    22.37  =\"0.00\"     1.38  =\"0.00\"   \n",
       "16  758000.0  758357.61  =\"0.00\"  =\"0.00\"  =\"0.00\"  =\"0.00\"   \n",
       "\n",
       "                                           备注   币种  \n",
       "0                股息入账:赣粤高速600269; 权益股数:40700;  人民币  \n",
       "1                   融券购回:18.63实际占款天数：7-888880  人民币  \n",
       "2                                        证券卖出  人民币  \n",
       "3                                        证券买入  人民币  \n",
       "4                                        证券买入  人民币  \n",
       "5                                        证券买入  人民币  \n",
       "6                                        证券买入  人民币  \n",
       "7                                        证券卖出  人民币  \n",
       "8                                        证券卖出  人民币  \n",
       "9                                        证券卖出  人民币  \n",
       "10                                       证券买入  人民币  \n",
       "11                                       证券买入  人民币  \n",
       "12  融券回购购回日:20220718预计利息:18.63参考占款天数：7-888880  人民币  \n",
       "13                                       证券买入  人民币  \n",
       "14                                       证券买入  人民币  \n",
       "15                                       证券买入  人民币  \n",
       "16                 融券购回:357.61实际占款天数：7-888880  人民币  "
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_pandas()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "9e887869-57c9-45f7-8786-36ebe9eb3803",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<bound method DataFrame.to_arrow of shape: (17, 16)\n",
       "┌──────────┬───────────┬──────────┬──────────┬───┬─────────┬─────────┬─────────────────────────────────┬────────┐\n",
       "│ 发生日期 ┆ 证券代码  ┆ 证券名称 ┆ 买卖标志 ┆ … ┆ 过户费  ┆ 其他费  ┆ 备注                            ┆ 币种   │\n",
       "│ ---      ┆ ---       ┆ ---      ┆ ---      ┆   ┆ ---     ┆ ---     ┆ ---                             ┆ ---    │\n",
       "│ i64      ┆ str       ┆ str      ┆ str      ┆   ┆ str     ┆ str     ┆ str                             ┆ str    │\n",
       "╞══════════╪═══════════╪══════════╪══════════╪═══╪═════════╪═════════╪═════════════════════════════════╪════════╡\n",
       "│ 20220721 ┆ 600269    ┆ 赣粤高速 ┆ 卖出     ┆ … ┆ =\"0.00\" ┆ =\"0.00\" ┆ 股息入账:赣粤高速600269;        ┆ 人民币 │\n",
       "│          ┆           ┆          ┆          ┆   ┆         ┆         ┆ 权益股数:40700;                 ┆        │\n",
       "│ 20220718 ┆ 204007    ┆ GC007    ┆ 卖出     ┆ … ┆ =\"0.00\" ┆ =\"0.00\" ┆ 融券购回:18.63实际占款天数：7-8 ┆ 人民币 │\n",
       "│          ┆           ┆          ┆          ┆   ┆         ┆         ┆ 88880                           ┆        │\n",
       "│ 20220718 ┆ =\"002462\" ┆ 嘉事堂   ┆ 卖出     ┆ … ┆ 1.38    ┆ =\"0.00\" ┆ 证券卖出                        ┆ 人民币 │\n",
       "│ 20220718 ┆ 600408    ┆ 安泰集团 ┆ 买入     ┆ … ┆ 1.51    ┆ =\"0.00\" ┆ 证券买入                        ┆ 人民币 │\n",
       "│ 20220718 ┆ 600648    ┆ 外高桥   ┆ 买入     ┆ … ┆ 1.49    ┆ =\"0.00\" ┆ 证券买入                        ┆ 人民币 │\n",
       "│ …        ┆ …         ┆ …        ┆ …        ┆ … ┆ …       ┆ …       ┆ …                               ┆ …      │\n",
       "│ 20220711 ┆ 204007    ┆ GC007    ┆ 卖出     ┆ … ┆ =\"0.00\" ┆ =\"0.00\" ┆ 融券回购购回日:20220718预计利息 ┆ 人民币 │\n",
       "│          ┆           ┆          ┆          ┆   ┆         ┆         ┆ :18.63参考占款…                 ┆        │\n",
       "│ 20220711 ┆ 601992    ┆ 金隅集团 ┆ 买入     ┆ … ┆ 1.42    ┆ =\"0.00\" ┆ 证券买入                        ┆ 人民币 │\n",
       "│ 20220711 ┆ 600894    ┆ 广日股份 ┆ 买入     ┆ … ┆ 1.41    ┆ =\"0.00\" ┆ 证券买入                        ┆ 人民币 │\n",
       "│ 20220711 ┆ 601077    ┆ 渝农商行 ┆ 买入     ┆ … ┆ 1.38    ┆ =\"0.00\" ┆ 证券买入                        ┆ 人民币 │\n",
       "│ 20220707 ┆ 204007    ┆ GC007    ┆ 卖出     ┆ … ┆ =\"0.00\" ┆ =\"0.00\" ┆ 融券购回:357.61实际占款天数：7- ┆ 人民币 │\n",
       "│          ┆           ┆          ┆          ┆   ┆         ┆         ┆ 888880                          ┆        │\n",
       "└──────────┴───────────┴──────────┴──────────┴───┴─────────┴─────────┴─────────────────────────────────┴────────┘>"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_arrow"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "15e19d1f-e81e-4c87-bdf1-880f836a524b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pyarrow.Table\n",
       "发生日期: int64\n",
       "证券代码: large_string\n",
       "证券名称: large_string\n",
       "买卖标志: large_string\n",
       "业务名称: large_string\n",
       "成交时间: large_string\n",
       "成交数量: large_string\n",
       "成交价格: double\n",
       "成交金额: double\n",
       "发生金额: double\n",
       "手续费: large_string\n",
       "印花税: large_string\n",
       "过户费: large_string\n",
       "其他费: large_string\n",
       "备注: large_string\n",
       "币种: large_string\n",
       "----\n",
       "发生日期: [[20220721,20220718,20220718,20220718,20220718,...,20220711,20220711,20220711,20220711,20220707]]\n",
       "证券代码: [[\"600269\",\"204007\",\"=\"002462\"\",\"600408\",\"600648\",...,\"204007\",\"601992\",\"600894\",\"601077\",\"204007\"]]\n",
       "证券名称: [[\"赣粤高速\",\"GC007\",\"嘉事堂\",\"安泰集团\",\"外高桥\",...,\"GC007\",\"金隅集团\",\"广日股份\",\"渝农商行\",\"GC007\"]]\n",
       "买卖标志: [[\"卖出\",\"卖出\",\"卖出\",\"买入\",\"买入\",...,\"卖出\",\"买入\",\"买入\",\"买入\",\"卖出\"]]\n",
       "业务名称: [[\"股息入账\",\"拆出质押购回\",\"证券卖出\",\"证券买入\",\"证券买入\",...,\"质押回购拆出\",\"证券买入\",\"证券买入\",\"证券买入\",\"拆出质押购回\"]]\n",
       "成交时间: [[\"16:00:00\",\"19:03:27\",\"09:38:10\",\"09:44:52\",\"09:44:31\",...,\"09:39:27\",\"09:37:25\",\"09:36:30\",\"09:34:24\",\"19:17:51\"]]\n",
       "成交数量: [[\"=\"0.00\"\",\"-580.00\",\"-10400.00\",\"47000.00\",\"11900.00\",...,\"580.00\",\"54000.00\",\"21400.00\",\"38300.00\",\"-7580.00\"]]\n",
       "成交价格: [[3.6,1.675,13.2062,3.19,12.6066,...,1.675,2.59,6.54,3.65,2.46]]\n",
       "成交金额: [[4884,58000,137344,149930,150019,...,58000,139860,139956,139795,758000]]\n",
       "发生金额: [[4884,58018.63,137184.67,-149955.5,-150044.49,...,-58002.9,-139883.8,-139979.8,-139818.75,758357.61]]\n",
       "..."
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_arrow()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "50e528ee-17ae-4c99-b2ce-2c3e794de351",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'发生日期': 20220721,\n",
       "  '证券代码': '600269',\n",
       "  '证券名称': '赣粤高速',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '股息入账',\n",
       "  '成交时间': '16:00:00',\n",
       "  '成交数量': '=\"0.00\"',\n",
       "  '成交价格': 3.6,\n",
       "  '成交金额': 4884.0,\n",
       "  '发生金额': 4884.0,\n",
       "  '手续费': '=\"0.00\"',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '=\"0.00\"',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '股息入账:赣粤高速600269; 权益股数:40700;',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '204007',\n",
       "  '证券名称': 'GC007',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '拆出质押购回',\n",
       "  '成交时间': '19:03:27',\n",
       "  '成交数量': '-580.00',\n",
       "  '成交价格': 1.675,\n",
       "  '成交金额': 58000.0,\n",
       "  '发生金额': 58018.63,\n",
       "  '手续费': '=\"0.00\"',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '=\"0.00\"',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '融券购回:18.63实际占款天数：7-888880',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '=\"002462\"',\n",
       "  '证券名称': '嘉事堂',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '证券卖出',\n",
       "  '成交时间': '09:38:10',\n",
       "  '成交数量': '-10400.00',\n",
       "  '成交价格': 13.2062,\n",
       "  '成交金额': 137344.0,\n",
       "  '发生金额': 137184.67,\n",
       "  '手续费': '21.98',\n",
       "  '印花税': '137.35',\n",
       "  '过户费': '1.38',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券卖出',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '600408',\n",
       "  '证券名称': '安泰集团',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:44:52',\n",
       "  '成交数量': '47000.00',\n",
       "  '成交价格': 3.19,\n",
       "  '成交金额': 149930.0,\n",
       "  '发生金额': -149955.5,\n",
       "  '手续费': '23.99',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.51',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '600648',\n",
       "  '证券名称': '外高桥',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:44:31',\n",
       "  '成交数量': '11900.00',\n",
       "  '成交价格': 12.6066,\n",
       "  '成交金额': 150019.0,\n",
       "  '发生金额': -150044.49,\n",
       "  '手续费': '24.00',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.49',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '600269',\n",
       "  '证券名称': '赣粤高速',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:43:38',\n",
       "  '成交数量': '40700.00',\n",
       "  '成交价格': 3.69,\n",
       "  '成交金额': 150183.0,\n",
       "  '发生金额': -150208.53,\n",
       "  '手续费': '24.03',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.50',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '600015',\n",
       "  '证券名称': '华夏银行',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:42:51',\n",
       "  '成交数量': '30000.00',\n",
       "  '成交价格': 5.07,\n",
       "  '成交金额': 152100.0,\n",
       "  '发生金额': -152125.86,\n",
       "  '手续费': '24.34',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.52',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '601992',\n",
       "  '证券名称': '金隅集团',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '证券卖出',\n",
       "  '成交时间': '09:39:28',\n",
       "  '成交数量': '-54000.00',\n",
       "  '成交价格': 2.5683,\n",
       "  '成交金额': 138686.0,\n",
       "  '发生金额': 138523.74,\n",
       "  '手续费': '22.19',\n",
       "  '印花税': '138.69',\n",
       "  '过户费': '1.38',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券卖出',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '600894',\n",
       "  '证券名称': '广日股份',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '证券卖出',\n",
       "  '成交时间': '09:39:06',\n",
       "  '成交数量': '-21400.00',\n",
       "  '成交价格': 6.5419,\n",
       "  '成交金额': 139996.0,\n",
       "  '发生金额': 139832.12,\n",
       "  '手续费': '22.40',\n",
       "  '印花税': '140.02',\n",
       "  '过户费': '1.46',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券卖出',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220718,\n",
       "  '证券代码': '601077',\n",
       "  '证券名称': '渝农商行',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '证券卖出',\n",
       "  '成交时间': '09:38:30',\n",
       "  '成交数量': '-38300.00',\n",
       "  '成交价格': 3.58,\n",
       "  '成交金额': 137114.0,\n",
       "  '发生金额': 136953.55,\n",
       "  '手续费': '21.94',\n",
       "  '印花税': '137.13',\n",
       "  '过户费': '1.38',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券卖出',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '=\"002462\"',\n",
       "  '证券名称': '嘉事堂',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:38:16',\n",
       "  '成交数量': '10400.00',\n",
       "  '成交价格': 13.51,\n",
       "  '成交金额': 140504.0,\n",
       "  '发生金额': -140526.48,\n",
       "  '手续费': '22.48',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.41',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '=\"000900\"',\n",
       "  '证券名称': '现代投资',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:33:37',\n",
       "  '成交数量': '34400.00',\n",
       "  '成交价格': 4.05,\n",
       "  '成交金额': 139320.0,\n",
       "  '发生金额': -139342.29,\n",
       "  '手续费': '22.29',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.39',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '204007',\n",
       "  '证券名称': 'GC007',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '质押回购拆出',\n",
       "  '成交时间': '09:39:27',\n",
       "  '成交数量': '580.00',\n",
       "  '成交价格': 1.675,\n",
       "  '成交金额': 58000.0,\n",
       "  '发生金额': -58002.9,\n",
       "  '手续费': '2.90',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '=\"0.00\"',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '融券回购购回日:20220718预计利息:18.63参考占款天数：7-888880',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '601992',\n",
       "  '证券名称': '金隅集团',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:37:25',\n",
       "  '成交数量': '54000.00',\n",
       "  '成交价格': 2.59,\n",
       "  '成交金额': 139860.0,\n",
       "  '发生金额': -139883.8,\n",
       "  '手续费': '22.38',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.42',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '600894',\n",
       "  '证券名称': '广日股份',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:36:30',\n",
       "  '成交数量': '21400.00',\n",
       "  '成交价格': 6.54,\n",
       "  '成交金额': 139956.0,\n",
       "  '发生金额': -139979.8,\n",
       "  '手续费': '22.39',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.41',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220711,\n",
       "  '证券代码': '601077',\n",
       "  '证券名称': '渝农商行',\n",
       "  '买卖标志': '买入',\n",
       "  '业务名称': '证券买入',\n",
       "  '成交时间': '09:34:24',\n",
       "  '成交数量': '38300.00',\n",
       "  '成交价格': 3.65,\n",
       "  '成交金额': 139795.0,\n",
       "  '发生金额': -139818.75,\n",
       "  '手续费': '22.37',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '1.38',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '证券买入',\n",
       "  '币种': '人民币'},\n",
       " {'发生日期': 20220707,\n",
       "  '证券代码': '204007',\n",
       "  '证券名称': 'GC007',\n",
       "  '买卖标志': '卖出',\n",
       "  '业务名称': '拆出质押购回',\n",
       "  '成交时间': '19:17:51',\n",
       "  '成交数量': '-7580.00',\n",
       "  '成交价格': 2.46,\n",
       "  '成交金额': 758000.0,\n",
       "  '发生金额': 758357.61,\n",
       "  '手续费': '=\"0.00\"',\n",
       "  '印花税': '=\"0.00\"',\n",
       "  '过户费': '=\"0.00\"',\n",
       "  '其他费': '=\"0.00\"',\n",
       "  '备注': '融券购回:357.61实际占款天数：7-888880',\n",
       "  '币种': '人民币'}]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_dicts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "795fa59a-cd4b-4d1e-9d31-0f8ff2ee4835",
   "metadata": {},
   "outputs": [],
   "source": [
    "s = df.to_series()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "427a392d-4076-4825-a290-40c172234fd6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'发生日期'"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "06663b6c-20ad-4059-b39a-29d9f8fd36f7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Int64"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.dtype"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "08986198-e328-4aab-96ec-30a16476b19a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(17,)"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "9f47c163-582e-4085-9832-2fee3c1654f6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (5,)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th></tr><tr><td>i64</td></tr></thead><tbody><tr><td>20220721</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (5,)\n",
       "Series: '发生日期' [i64]\n",
       "[\n",
       "\t20220721\n",
       "\t20220718\n",
       "\t20220718\n",
       "\t20220718\n",
       "\t20220718\n",
       "]"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s[:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "304e3200-2b4f-469c-a286-6c3646105cba",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (12,)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th></tr><tr><td>i64</td></tr></thead><tbody><tr><td>20220718</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr><tr><td>20220718</td></tr><tr><td>&hellip;</td></tr><tr><td>20220711</td></tr><tr><td>20220711</td></tr><tr><td>20220711</td></tr><tr><td>20220711</td></tr><tr><td>20220707</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (12,)\n",
       "Series: '发生日期' [i64]\n",
       "[\n",
       "\t20220718\n",
       "\t20220718\n",
       "\t20220718\n",
       "\t20220718\n",
       "\t20220718\n",
       "\t…\n",
       "\t20220711\n",
       "\t20220711\n",
       "\t20220711\n",
       "\t20220711\n",
       "\t20220707\n",
       "]"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s[5:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "c2f6fae9-739f-41a8-a365-1a33a25cd480",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<bound method Series.unique of shape: (17,)\n",
       "Series: '买卖标志' [str]\n",
       "[\n",
       "\t\"卖出\"\n",
       "\t\"卖出\"\n",
       "\t\"卖出\"\n",
       "\t\"买入\"\n",
       "\t\"买入\"\n",
       "\t…\n",
       "\t\"卖出\"\n",
       "\t\"买入\"\n",
       "\t\"买入\"\n",
       "\t\"买入\"\n",
       "\t\"卖出\"\n",
       "]>"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_series(3).unique"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "8ad4aea8-7b3a-47e7-b220-7c8c0f02a215",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.to_series(3).null_count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "f37205ac-7a7e-4aba-94cc-ac4db6c41d6a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Rows: 17\n",
      "Columns: 16\n",
      "$ 发生日期 <i64> 20220721, 20220718, 20220718, 20220718, 20220718, 20220718, 20220718, 20220718, 20220718, 20220718\n",
      "$ 证券代码 <str> '600269', '204007', '=\"002462\"', '600408', '600648', '600269', '600015', '601992', '600894', '601077'\n",
      "$ 证券名称 <str> '赣粤高速', 'GC007', '嘉事堂', '安泰集团', '外高桥', '赣粤高速', '华夏银行', '金隅集团', '广日股份', '渝农商行'\n",
      "$ 买卖标志 <str> '卖出', '卖出', '卖出', '买入', '买入', '买入', '买入', '卖出', '卖出', '卖出'\n",
      "$ 业务名称 <str> '股息入账', '拆出质押购回', '证券卖出', '证券买入', '证券买入', '证券买入', '证券买入', '证券卖出', '证券卖出', '证券卖出'\n",
      "$ 成交时间 <str> '16:00:00', '19:03:27', '09:38:10', '09:44:52', '09:44:31', '09:43:38', '09:42:51', '09:39:28', '09:39:06', '09:38:30'\n",
      "$ 成交数量 <str> '=\"0.00\"', '-580.00', '-10400.00', '47000.00', '11900.00', '40700.00', '30000.00', '-54000.00', '-21400.00', '-38300.00'\n",
      "$ 成交价格 <f64> 3.6, 1.675, 13.2062, 3.19, 12.6066, 3.69, 5.07, 2.5683, 6.5419, 3.58\n",
      "$ 成交金额 <f64> 4884.0, 58000.0, 137344.0, 149930.0, 150019.0, 150183.0, 152100.0, 138686.0, 139996.0, 137114.0\n",
      "$ 发生金额 <f64> 4884.0, 58018.63, 137184.67, -149955.5, -150044.49, -150208.53, -152125.86, 138523.74, 139832.12, 136953.55\n",
      "$ 手续费  <str> '=\"0.00\"', '=\"0.00\"', '21.98', '23.99', '24.00', '24.03', '24.34', '22.19', '22.40', '21.94'\n",
      "$ 印花税  <str> '=\"0.00\"', '=\"0.00\"', '137.35', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '138.69', '140.02', '137.13'\n",
      "$ 过户费  <str> '=\"0.00\"', '=\"0.00\"', '1.38', '1.51', '1.49', '1.50', '1.52', '1.38', '1.46', '1.38'\n",
      "$ 其他费  <str> '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"', '=\"0.00\"'\n",
      "$ 备注   <str> '股息入账:赣粤高速600269; 权益股数:40700;', '融券购回:18.63实际占款天数：7-888880', '证券卖出', '证券买入', '证券买入', '证券买入', '证券买入', '证券卖出', '证券卖出', '证券卖出'\n",
      "$ 币种   <str> '人民币', '人民币', '人民币', '人民币', '人民币', '人民币', '人民币', '人民币', '人民币', '人民币'\n",
      "\n"
     ]
    }
   ],
   "source": [
    "df.glimpse()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "c474d120-5420-4dc7-aa9d-1d5d991fa4f1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (3, 2)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>foe</th><th>foo2</th></tr><tr><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;asldjl&quot;</td><td>&quot;sldj&quot;</td></tr><tr><td>&quot;jjjask&quot;</td><td>&quot;jjjask&quot;</td></tr><tr><td>&quot;hasnc&quot;</td><td>&quot;hasnc&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (3, 2)\n",
       "┌────────┬────────┐\n",
       "│ foe    ┆ foo2   │\n",
       "│ ---    ┆ ---    │\n",
       "│ str    ┆ str    │\n",
       "╞════════╪════════╡\n",
       "│ asldjl ┆ sldj   │\n",
       "│ jjjask ┆ jjjask │\n",
       "│ hasnc  ┆ hasnc  │\n",
       "└────────┴────────┘"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pl.DataFrame({\"foe\": [\"asldjl\", \"jjjask\", \"hasnc\"]})\n",
    "\n",
    "df.with_columns(foo2=pl.col(\"foe\").str.strip_chars(\"al\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "b74ef40c-a921-4616-aa11-3ec36208d44d",
   "metadata": {},
   "outputs": [],
   "source": [
    "def read_df_湘财(f: str | Path) -> pl.DataFrame:\n",
    "    df = pl.read_csv(\n",
    "        f,\n",
    "        encoding=\"gb18030\",\n",
    "        separator=\"\\t\",\n",
    "        infer_schema=False,\n",
    "    )\n",
    "    df = df.with_columns(\n",
    "        pl.selectors.all().str.strip_prefix(\"=\").str.strip_chars('\"'),\n",
    "    )\n",
    "    df = df.with_columns(\n",
    "        pl.col(\"发生日期\").cast(pl.Utf8).str.to_date(\"%Y%m%d\"),\n",
    "        pl.col(\"成交时间\").str.to_time(),\n",
    "        pl.col(\n",
    "            \"成交数量\",\n",
    "            \"成交价格\",\n",
    "            \"成交金额\",\n",
    "            \"发生金额\",\n",
    "            \"手续费\",\n",
    "            \"印花税\",\n",
    "            \"过户费\",\n",
    "            \"其他费\",\n",
    "        ).cast(pl.Float64),\n",
    "    )\n",
    "    df = df.filter(\n",
    "        pl.col(\"业务名称\").is_in([\"证券买入\", \"证券卖出\"]),\n",
    "    )\n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "id": "8d772727-fe77-44c1-a3b4-db93495804b0",
   "metadata": {},
   "outputs": [],
   "source": [
    "from pathlib import Path"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "id": "a87f53ca-5e44-4631-bf9a-44742aa0c6e2",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = [read_df_湘财(f) for f in Path(\"stock_trades/\").glob(\"*-湘财.xls\")]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "08bbbcb8-eba6-4429-b7ca-d93415e35098",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1 = pl.concat(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "id": "0f1efa03-401b-4656-98d5-b1f376a8db02",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1 = d1.with_columns(\n",
    "    券商=pl.lit(\"湘财\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "id": "d30b8fac-4811-4fc7-a062-8f0bdb1041d1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (257, 17)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>发生日期</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>业务名称</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>币种</th><th>券商</th></tr><tr><td>date</td><td>str</td><td>str</td><td>str</td><td>str</td><td>time</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>2022-07-18</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>09:38:10</td><td>-10400.0</td><td>13.2062</td><td>137344.0</td><td>137184.67</td><td>21.98</td><td>137.35</td><td>1.38</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:44:52</td><td>47000.0</td><td>3.19</td><td>149930.0</td><td>-149955.5</td><td>23.99</td><td>0.0</td><td>1.51</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:44:31</td><td>11900.0</td><td>12.6066</td><td>150019.0</td><td>-150044.49</td><td>24.0</td><td>0.0</td><td>1.49</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:43:38</td><td>40700.0</td><td>3.69</td><td>150183.0</td><td>-150208.53</td><td>24.03</td><td>0.0</td><td>1.5</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2022-07-18</td><td>&quot;600015&quot;</td><td>&quot;华夏银行&quot;</td><td>&quot;买入&quot;</td><td>&quot;证券买入&quot;</td><td>09:42:51</td><td>30000.0</td><td>5.07</td><td>152100.0</td><td>-152125.86</td><td>24.34</td><td>0.0</td><td>1.52</td><td>0.0</td><td>&quot;证券买入&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>2023-06-19</td><td>&quot;603967&quot;</td><td>&quot;中创物流&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>10:18:46</td><td>-5000.0</td><td>9.13</td><td>45650.0</td><td>45596.59</td><td>7.3</td><td>45.65</td><td>0.46</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2023-06-12</td><td>&quot;300641&quot;</td><td>&quot;正丹股份&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>13:22:32</td><td>-9600.0</td><td>5.05</td><td>48480.0</td><td>48423.76</td><td>7.76</td><td>48.48</td><td>0.48</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2023-06-02</td><td>&quot;000655&quot;</td><td>&quot;金岭矿业&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>10:26:35</td><td>-7500.0</td><td>6.48</td><td>48600.0</td><td>48543.61</td><td>7.78</td><td>48.61</td><td>0.47</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2023-06-01</td><td>&quot;300214&quot;</td><td>&quot;日科化学&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>10:45:35</td><td>-7400.0</td><td>6.8</td><td>50320.0</td><td>50261.63</td><td>8.05</td><td>50.32</td><td>0.51</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr><tr><td>2023-09-11</td><td>&quot;603577&quot;</td><td>&quot;汇金通&quot;</td><td>&quot;卖出&quot;</td><td>&quot;证券卖出&quot;</td><td>09:46:10</td><td>-5100.0</td><td>9.3024</td><td>47442.0</td><td>47410.89</td><td>6.9</td><td>23.72</td><td>0.49</td><td>0.0</td><td>&quot;证券卖出&quot;</td><td>&quot;人民币&quot;</td><td>&quot;湘财&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (257, 17)\n",
       "┌────────────┬──────────┬──────────┬──────────┬───┬────────┬──────────┬────────┬──────┐\n",
       "│ 发生日期   ┆ 证券代码 ┆ 证券名称 ┆ 买卖标志 ┆ … ┆ 其他费 ┆ 备注     ┆ 币种   ┆ 券商 │\n",
       "│ ---        ┆ ---      ┆ ---      ┆ ---      ┆   ┆ ---    ┆ ---      ┆ ---    ┆ ---  │\n",
       "│ date       ┆ str      ┆ str      ┆ str      ┆   ┆ f64    ┆ str      ┆ str    ┆ str  │\n",
       "╞════════════╪══════════╪══════════╪══════════╪═══╪════════╪══════════╪════════╪══════╡\n",
       "│ 2022-07-18 ┆ 002462   ┆ 嘉事堂   ┆ 卖出     ┆ … ┆ 0.0    ┆ 证券卖出 ┆ 人民币 ┆ 湘财 │\n",
       "│ 2022-07-18 ┆ 600408   ┆ 安泰集团 ┆ 买入     ┆ … ┆ 0.0    ┆ 证券买入 ┆ 人民币 ┆ 湘财 │\n",
       "│ 2022-07-18 ┆ 600648   ┆ 外高桥   ┆ 买入     ┆ … ┆ 0.0    ┆ 证券买入 ┆ 人民币 ┆ 湘财 │\n",
       "│ 2022-07-18 ┆ 600269   ┆ 赣粤高速 ┆ 买入     ┆ … ┆ 0.0    ┆ 证券买入 ┆ 人民币 ┆ 湘财 │\n",
       "│ 2022-07-18 ┆ 600015   ┆ 华夏银行 ┆ 买入     ┆ … ┆ 0.0    ┆ 证券买入 ┆ 人民币 ┆ 湘财 │\n",
       "│ …          ┆ …        ┆ …        ┆ …        ┆ … ┆ …      ┆ …        ┆ …      ┆ …    │\n",
       "│ 2023-06-19 ┆ 603967   ┆ 中创物流 ┆ 卖出     ┆ … ┆ 0.0    ┆ 证券卖出 ┆ 人民币 ┆ 湘财 │\n",
       "│ 2023-06-12 ┆ 300641   ┆ 正丹股份 ┆ 卖出     ┆ … ┆ 0.0    ┆ 证券卖出 ┆ 人民币 ┆ 湘财 │\n",
       "│ 2023-06-02 ┆ 000655   ┆ 金岭矿业 ┆ 卖出     ┆ … ┆ 0.0    ┆ 证券卖出 ┆ 人民币 ┆ 湘财 │\n",
       "│ 2023-06-01 ┆ 300214   ┆ 日科化学 ┆ 卖出     ┆ … ┆ 0.0    ┆ 证券卖出 ┆ 人民币 ┆ 湘财 │\n",
       "│ 2023-09-11 ┆ 603577   ┆ 汇金通   ┆ 卖出     ┆ … ┆ 0.0    ┆ 证券卖出 ┆ 人民币 ┆ 湘财 │\n",
       "└────────────┴──────────┴──────────┴──────────┴───┴────────┴──────────┴────────┴──────┘"
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 159,
   "id": "17786d16-40d0-44f7-89ee-285853eac1de",
   "metadata": {},
   "outputs": [],
   "source": [
    "def read_df_海通普通(f: str | Path) -> pl.DataFrame:\n",
    "    df = pl.read_excel(\n",
    "        f,\n",
    "        schema_overrides={\n",
    "            \"成交日期\": pl.String,\n",
    "            \"成交时间\": pl.String,\n",
    "            \"成交数量\": pl.Float64,\n",
    "            \"成交金额\": pl.Float64,\n",
    "            \"印花税\": pl.Float64,\n",
    "            \"其他费\": pl.Float64,\n",
    "        },\n",
    "    )\n",
    "    df = df.filter(\n",
    "        (pl.col(\"成交时间\") != \"\")\n",
    "        & (pl.col(\"操作\").is_in({\"买\", \"卖\"}))\n",
    "        & (~pl.col(\"证券代码\").str.starts_with(\"204\"))\n",
    "        & (~pl.col(\"证券代码\").str.starts_with(\"1318\"))\n",
    "    ).with_columns(\n",
    "        pl.col(\"成交日期\").str.to_date(\"%Y%m%d\"),\n",
    "        pl.col(\"成交时间\").str.to_time(\"%H:%M:%S\"),\n",
    "    )\n",
    "    return df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 162,
   "id": "4b027307-bd5b-4ef5-961a-04d78883ff8d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (53, 15)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th><th>证券名称</th><th>成交日期</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>操作</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>券商</th></tr><tr><td>str</td><td>str</td><td>date</td><td>time</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;002224&quot;</td><td>&quot;三 力 士&quot;</td><td>2023-05-23</td><td>09:58:07</td><td>10800.0</td><td>4.59</td><td>49572.0</td><td>-49576.96</td><td>&quot;买&quot;</td><td>4.96</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;三 力 士证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;300107&quot;</td><td>&quot;建新股份&quot;</td><td>2023-05-23</td><td>10:01:57</td><td>10000.0</td><td>5.0</td><td>50000.0</td><td>-50005.0</td><td>&quot;买&quot;</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;建新股份证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;603002&quot;</td><td>&quot;宏昌电子&quot;</td><td>2023-05-24</td><td>09:54:48</td><td>9800.0</td><td>5.06</td><td>49588.0</td><td>-49593.46</td><td>&quot;买&quot;</td><td>4.96</td><td>0.0</td><td>0.5</td><td>0.0</td><td>&quot;宏昌电子证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;600178&quot;</td><td>&quot;东安动力&quot;</td><td>2023-05-24</td><td>09:59:17</td><td>16400.0</td><td>6.07</td><td>99548.0</td><td>-99558.97</td><td>&quot;买&quot;</td><td>9.95</td><td>0.0</td><td>1.02</td><td>0.0</td><td>&quot;东安动力证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;600626&quot;</td><td>&quot;申达股份&quot;</td><td>2023-05-24</td><td>10:06:14</td><td>14800.0</td><td>3.37</td><td>49876.0</td><td>-49881.48</td><td>&quot;买&quot;</td><td>4.99</td><td>0.0</td><td>0.49</td><td>0.0</td><td>&quot;申达股份证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;603386&quot;</td><td>&quot;骏亚科技&quot;</td><td>2023-07-24</td><td>09:38:22</td><td>4500.0</td><td>11.32</td><td>50940.0</td><td>50883.51</td><td>&quot;卖&quot;</td><td>5.09</td><td>50.91</td><td>0.49</td><td>0.0</td><td>&quot;骏亚科技证券卖出&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;002225&quot;</td><td>&quot;濮耐股份&quot;</td><td>2023-07-24</td><td>09:42:11</td><td>13200.0</td><td>3.8</td><td>50160.0</td><td>-50165.02</td><td>&quot;买&quot;</td><td>5.02</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;濮耐股份证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;600735&quot;</td><td>&quot;新华锦&quot;</td><td>2023-07-24</td><td>09:48:27</td><td>8200.0</td><td>6.07</td><td>49774.0</td><td>-49779.48</td><td>&quot;买&quot;</td><td>4.98</td><td>0.0</td><td>0.5</td><td>0.0</td><td>&quot;新华锦证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;300642&quot;</td><td>&quot;透景生命&quot;</td><td>2023-07-24</td><td>09:49:52</td><td>2500.0</td><td>19.69</td><td>49225.0</td><td>-49229.92</td><td>&quot;买&quot;</td><td>4.92</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;透景生命证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr><tr><td>&quot;000823&quot;</td><td>&quot;超声电子&quot;</td><td>2023-07-24</td><td>09:52:23</td><td>5400.0</td><td>9.38</td><td>50652.0</td><td>-50657.07</td><td>&quot;买&quot;</td><td>5.07</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;超声电子证券买入&quot;</td><td>&quot;海通普通&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (53, 15)\n",
       "┌──────────┬──────────┬────────────┬──────────┬───┬────────┬────────┬──────────────────┬──────────┐\n",
       "│ 证券代码 ┆ 证券名称 ┆ 成交日期   ┆ 成交时间 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注             ┆ 券商     │\n",
       "│ ---      ┆ ---      ┆ ---        ┆ ---      ┆   ┆ ---    ┆ ---    ┆ ---              ┆ ---      │\n",
       "│ str      ┆ str      ┆ date       ┆ time     ┆   ┆ f64    ┆ f64    ┆ str              ┆ str      │\n",
       "╞══════════╪══════════╪════════════╪══════════╪═══╪════════╪════════╪══════════════════╪══════════╡\n",
       "│ 002224   ┆ 三 力 士 ┆ 2023-05-23 ┆ 09:58:07 ┆ … ┆ 0.0    ┆ 0.0    ┆ 三 力 士证券买入 ┆ 海通普通 │\n",
       "│ 300107   ┆ 建新股份 ┆ 2023-05-23 ┆ 10:01:57 ┆ … ┆ 0.0    ┆ 0.0    ┆ 建新股份证券买入 ┆ 海通普通 │\n",
       "│ 603002   ┆ 宏昌电子 ┆ 2023-05-24 ┆ 09:54:48 ┆ … ┆ 0.5    ┆ 0.0    ┆ 宏昌电子证券买入 ┆ 海通普通 │\n",
       "│ 600178   ┆ 东安动力 ┆ 2023-05-24 ┆ 09:59:17 ┆ … ┆ 1.02   ┆ 0.0    ┆ 东安动力证券买入 ┆ 海通普通 │\n",
       "│ 600626   ┆ 申达股份 ┆ 2023-05-24 ┆ 10:06:14 ┆ … ┆ 0.49   ┆ 0.0    ┆ 申达股份证券买入 ┆ 海通普通 │\n",
       "│ …        ┆ …        ┆ …          ┆ …        ┆ … ┆ …      ┆ …      ┆ …                ┆ …        │\n",
       "│ 603386   ┆ 骏亚科技 ┆ 2023-07-24 ┆ 09:38:22 ┆ … ┆ 0.49   ┆ 0.0    ┆ 骏亚科技证券卖出 ┆ 海通普通 │\n",
       "│ 002225   ┆ 濮耐股份 ┆ 2023-07-24 ┆ 09:42:11 ┆ … ┆ 0.0    ┆ 0.0    ┆ 濮耐股份证券买入 ┆ 海通普通 │\n",
       "│ 600735   ┆ 新华锦   ┆ 2023-07-24 ┆ 09:48:27 ┆ … ┆ 0.5    ┆ 0.0    ┆ 新华锦证券买入   ┆ 海通普通 │\n",
       "│ 300642   ┆ 透景生命 ┆ 2023-07-24 ┆ 09:49:52 ┆ … ┆ 0.0    ┆ 0.0    ┆ 透景生命证券买入 ┆ 海通普通 │\n",
       "│ 000823   ┆ 超声电子 ┆ 2023-07-24 ┆ 09:52:23 ┆ … ┆ 0.0    ┆ 0.0    ┆ 超声电子证券买入 ┆ 海通普通 │\n",
       "└──────────┴──────────┴────────────┴──────────┴───┴────────┴────────┴──────────────────┴──────────┘"
      ]
     },
     "execution_count": 162,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = [read_df_海通普通(p) for p in Path(\"stock_trades/\").glob(\"*-海通普通.xlsx\")]\n",
    "df = pl.concat(df)\n",
    "d2 = df.with_columns(\n",
    "    券商=pl.lit(\"海通普通\"),\n",
    ")\n",
    "d2.sort(\"成交日期\", \"成交时间\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 164,
   "id": "6bd386e0-a64d-4e25-8a7a-38fabc512258",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (53, 15)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>证券代码</th><th>证券名称</th><th>成交日期</th><th>成交时间</th><th>成交数量</th><th>成交价格</th><th>成交金额</th><th>发生金额</th><th>操作</th><th>手续费</th><th>印花税</th><th>过户费</th><th>其他费</th><th>备注</th><th>券商</th></tr><tr><td>str</td><td>str</td><td>date</td><td>time</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>str</td><td>str</td></tr></thead><tbody><tr><td>&quot;600638&quot;</td><td>&quot;新黄浦&quot;</td><td>2023-07-26</td><td>09:33:56</td><td>9300.0</td><td>6.526</td><td>60696.0</td><td>60628.01</td><td>&quot;卖&quot;</td><td>6.68</td><td>60.7</td><td>0.61</td><td>0.0</td><td>&quot;新黄浦证券卖出&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;002492&quot;</td><td>&quot;恒基达鑫&quot;</td><td>2023-07-27</td><td>09:30:42</td><td>8700.0</td><td>6.12</td><td>53244.0</td><td>53184.91</td><td>&quot;卖&quot;</td><td>5.86</td><td>53.23</td><td>0.0</td><td>0.0</td><td>&quot;恒基达鑫证券卖出&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;002136&quot;</td><td>&quot;安 纳 达&quot;</td><td>2023-07-27</td><td>09:32:52</td><td>4400.0</td><td>11.881</td><td>52277.0</td><td>52218.97</td><td>&quot;卖&quot;</td><td>5.75</td><td>52.28</td><td>0.0</td><td>0.0</td><td>&quot;安 纳 达证券卖出&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;600300&quot;</td><td>&quot;维维股份&quot;</td><td>2023-08-04</td><td>09:36:55</td><td>16400.0</td><td>3.27</td><td>53628.0</td><td>53567.91</td><td>&quot;卖&quot;</td><td>5.9</td><td>53.65</td><td>0.54</td><td>0.0</td><td>&quot;维维股份证券卖出&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;300241&quot;</td><td>&quot;瑞丰光电&quot;</td><td>2023-08-04</td><td>09:39:38</td><td>9700.0</td><td>5.13</td><td>49761.0</td><td>-49766.47</td><td>&quot;买&quot;</td><td>5.47</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;瑞丰光电证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;002956&quot;</td><td>&quot;西麦食品&quot;</td><td>2023-10-31</td><td>09:31:53</td><td>5000.0</td><td>14.13</td><td>70650.0</td><td>70607.91</td><td>&quot;卖&quot;</td><td>6.74</td><td>35.35</td><td>0.0</td><td>0.0</td><td>&quot;西麦食品证券卖出&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;603214&quot;</td><td>&quot;爱婴室&quot;</td><td>2023-10-31</td><td>09:39:57</td><td>3100.0</td><td>15.84</td><td>49104.0</td><td>-49109.51</td><td>&quot;买&quot;</td><td>5.0</td><td>0.0</td><td>0.51</td><td>0.0</td><td>&quot;爱婴室证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;300132&quot;</td><td>&quot;青松股份&quot;</td><td>2023-10-31</td><td>09:40:55</td><td>9600.0</td><td>5.21</td><td>50016.0</td><td>-50021.0</td><td>&quot;买&quot;</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;青松股份证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;002492&quot;</td><td>&quot;恒基达鑫&quot;</td><td>2023-10-31</td><td>09:43:13</td><td>8400.0</td><td>5.91</td><td>49644.0</td><td>-49649.0</td><td>&quot;买&quot;</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;恒基达鑫证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr><tr><td>&quot;002111&quot;</td><td>&quot;威海广泰&quot;</td><td>2023-10-31</td><td>09:44:45</td><td>5400.0</td><td>9.24</td><td>49896.0</td><td>-49901.0</td><td>&quot;买&quot;</td><td>5.0</td><td>0.0</td><td>0.0</td><td>0.0</td><td>&quot;威海广泰证券买入&quot;</td><td>&quot;海通两融&quot;</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (53, 15)\n",
       "┌──────────┬──────────┬────────────┬──────────┬───┬────────┬────────┬──────────────────┬──────────┐\n",
       "│ 证券代码 ┆ 证券名称 ┆ 成交日期   ┆ 成交时间 ┆ … ┆ 过户费 ┆ 其他费 ┆ 备注             ┆ 券商     │\n",
       "│ ---      ┆ ---      ┆ ---        ┆ ---      ┆   ┆ ---    ┆ ---    ┆ ---              ┆ ---      │\n",
       "│ str      ┆ str      ┆ date       ┆ time     ┆   ┆ f64    ┆ f64    ┆ str              ┆ str      │\n",
       "╞══════════╪══════════╪════════════╪══════════╪═══╪════════╪════════╪══════════════════╪══════════╡\n",
       "│ 600638   ┆ 新黄浦   ┆ 2023-07-26 ┆ 09:33:56 ┆ … ┆ 0.61   ┆ 0.0    ┆ 新黄浦证券卖出   ┆ 海通两融 │\n",
       "│ 002492   ┆ 恒基达鑫 ┆ 2023-07-27 ┆ 09:30:42 ┆ … ┆ 0.0    ┆ 0.0    ┆ 恒基达鑫证券卖出 ┆ 海通两融 │\n",
       "│ 002136   ┆ 安 纳 达 ┆ 2023-07-27 ┆ 09:32:52 ┆ … ┆ 0.0    ┆ 0.0    ┆ 安 纳 达证券卖出 ┆ 海通两融 │\n",
       "│ 600300   ┆ 维维股份 ┆ 2023-08-04 ┆ 09:36:55 ┆ … ┆ 0.54   ┆ 0.0    ┆ 维维股份证券卖出 ┆ 海通两融 │\n",
       "│ 300241   ┆ 瑞丰光电 ┆ 2023-08-04 ┆ 09:39:38 ┆ … ┆ 0.0    ┆ 0.0    ┆ 瑞丰光电证券买入 ┆ 海通两融 │\n",
       "│ …        ┆ …        ┆ …          ┆ …        ┆ … ┆ …      ┆ …      ┆ …                ┆ …        │\n",
       "│ 002956   ┆ 西麦食品 ┆ 2023-10-31 ┆ 09:31:53 ┆ … ┆ 0.0    ┆ 0.0    ┆ 西麦食品证券卖出 ┆ 海通两融 │\n",
       "│ 603214   ┆ 爱婴室   ┆ 2023-10-31 ┆ 09:39:57 ┆ … ┆ 0.51   ┆ 0.0    ┆ 爱婴室证券买入   ┆ 海通两融 │\n",
       "│ 300132   ┆ 青松股份 ┆ 2023-10-31 ┆ 09:40:55 ┆ … ┆ 0.0    ┆ 0.0    ┆ 青松股份证券买入 ┆ 海通两融 │\n",
       "│ 002492   ┆ 恒基达鑫 ┆ 2023-10-31 ┆ 09:43:13 ┆ … ┆ 0.0    ┆ 0.0    ┆ 恒基达鑫证券买入 ┆ 海通两融 │\n",
       "│ 002111   ┆ 威海广泰 ┆ 2023-10-31 ┆ 09:44:45 ┆ … ┆ 0.0    ┆ 0.0    ┆ 威海广泰证券买入 ┆ 海通两融 │\n",
       "└──────────┴──────────┴────────────┴──────────┴───┴────────┴────────┴──────────────────┴──────────┘"
      ]
     },
     "execution_count": 164,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = [read_df_海通普通(p) for p in Path(\"stock_trades/\").glob(\"*-海通两融.xlsx\")]\n",
    "df = pl.concat(df)\n",
    "d3 = df.with_columns(\n",
    "    券商=pl.lit(\"海通两融\"),\n",
    ")\n",
    "d3.sort(\"成交日期\", \"成交时间\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 176,
   "id": "b8ec5100-6166-41ed-b581-b4bbd7417de8",
   "metadata": {},
   "outputs": [],
   "source": [
    "d1 = d1.select(\n",
    "    券商=pl.col(\"券商\"),\n",
    "    交易日期=pl.col(\"发生日期\"),\n",
    "    交易时间=pl.col(\"成交时间\"),\n",
    "    证券代码=pl.col(\"证券代码\"),\n",
    "    证券名称=pl.col(\"证券名称\"),\n",
    "    买卖标志=pl.col(\"业务名称\").replace({\"证券卖出\": \"卖出\", \"证券买入\": \"买入\"}),\n",
    "    成交价格=pl.col(\"成交价格\"),\n",
    "    成交数量=pl.col(\"成交数量\").abs(),\n",
    "    成交金额=pl.col(\"成交金额\"),\n",
    "    手续费=pl.col(\"手续费\"),\n",
    "    印花费=pl.col(\"印花税\"),\n",
    "    过户费=pl.col(\"过户费\"),\n",
    "    其他费=pl.col(\"其他费\"),\n",
    "    发生金额=pl.col(\"发生金额\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 179,
   "id": "48dd0514-495c-40f9-952e-c0fe10b859d2",
   "metadata": {},
   "outputs": [],
   "source": [
    "d2 = d2.select(\n",
    "    券商=pl.col(\"券商\"),\n",
    "    交易日期=pl.col(\"成交日期\"),\n",
    "    交易时间=pl.col(\"成交时间\"),\n",
    "    证券代码=pl.col(\"证券代码\"),\n",
    "    证券名称=pl.col(\"证券名称\"),\n",
    "    买卖标志=pl.col(\"操作\").replace({\"卖\": \"卖出\", \"买\": \"买入\"}),\n",
    "    成交价格=pl.col(\"成交价格\"),\n",
    "    成交数量=pl.col(\"成交数量\").abs(),\n",
    "    成交金额=pl.col(\"成交金额\"),\n",
    "    手续费=pl.col(\"手续费\"),\n",
    "    印花费=pl.col(\"印花税\"),\n",
    "    过户费=pl.col(\"过户费\"),\n",
    "    其他费=pl.col(\"其他费\"),\n",
    "    发生金额=pl.col(\"发生金额\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 183,
   "id": "80f2e031-e455-4350-9af6-214822a76062",
   "metadata": {},
   "outputs": [],
   "source": [
    "d3 = d3.select(\n",
    "    券商=pl.col(\"券商\"),\n",
    "    交易日期=pl.col(\"成交日期\"),\n",
    "    交易时间=pl.col(\"成交时间\"),\n",
    "    证券代码=pl.col(\"证券代码\"),\n",
    "    证券名称=pl.col(\"证券名称\"),\n",
    "    买卖标志=pl.col(\"操作\").replace({\"卖\": \"卖出\", \"买\": \"买入\"}),\n",
    "    成交价格=pl.col(\"成交价格\"),\n",
    "    成交数量=pl.col(\"成交数量\").abs(),\n",
    "    成交金额=pl.col(\"成交金额\"),\n",
    "    手续费=pl.col(\"手续费\"),\n",
    "    印花费=pl.col(\"印花税\"),\n",
    "    过户费=pl.col(\"过户费\"),\n",
    "    其他费=pl.col(\"其他费\"),\n",
    "    发生金额=pl.col(\"发生金额\"),\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 186,
   "id": "a5e81921-73cd-481a-96e6-664db862242f",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pl.concat([d1, d2, d3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 196,
   "id": "5cd7ba58-b66b-4a7b-b967-23e70d5317c3",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (363, 17)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>券商</th><th>交易日期</th><th>交易时间</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花费</th><th>过户费</th><th>其他费</th><th>发生金额</th><th>成交金额2</th><th>成交金额D</th><th>发生金额D</th></tr><tr><td>str</td><td>date</td><td>time</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:44:52</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>3.19</td><td>47000.0</td><td>149930.0</td><td>23.99</td><td>0.0</td><td>1.51</td><td>0.0</td><td>-149955.5</td><td>149930.0</td><td>0.0</td><td>0.0</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:44:31</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>12.6066</td><td>11900.0</td><td>150019.0</td><td>24.0</td><td>0.0</td><td>1.49</td><td>0.0</td><td>-150044.49</td><td>150018.54</td><td>0.46</td><td>0.0</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:43:38</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;买入&quot;</td><td>3.69</td><td>40700.0</td><td>150183.0</td><td>24.03</td><td>0.0</td><td>1.5</td><td>0.0</td><td>-150208.53</td><td>150183.0</td><td>0.0</td><td>0.0</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:42:51</td><td>&quot;600015&quot;</td><td>&quot;华夏银行&quot;</td><td>&quot;买入&quot;</td><td>5.07</td><td>30000.0</td><td>152100.0</td><td>24.34</td><td>0.0</td><td>1.52</td><td>0.0</td><td>-152125.86</td><td>152100.0</td><td>0.0</td><td>0.0</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:39:28</td><td>&quot;601992&quot;</td><td>&quot;金隅集团&quot;</td><td>&quot;卖出&quot;</td><td>2.5683</td><td>54000.0</td><td>138686.0</td><td>22.19</td><td>138.69</td><td>1.38</td><td>0.0</td><td>138523.74</td><td>138688.2</td><td>-2.2</td><td>0.0</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-10-24</td><td>09:37:27</td><td>&quot;300283&quot;</td><td>&quot;温州宏丰&quot;</td><td>&quot;买入&quot;</td><td>5.4038</td><td>12900.0</td><td>69709.0</td><td>11.15</td><td>0.0</td><td>0.83</td><td>0.0</td><td>-69720.15</td><td>69709.02</td><td>-0.02</td><td>0.83</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-10-11</td><td>09:32:03</td><td>&quot;000900&quot;</td><td>&quot;现代投资&quot;</td><td>&quot;卖出&quot;</td><td>3.8465</td><td>34400.0</td><td>132321.0</td><td>21.17</td><td>132.35</td><td>1.31</td><td>0.0</td><td>132167.48</td><td>132319.6</td><td>1.4</td><td>1.31</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:38:10</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>13.2062</td><td>10400.0</td><td>137344.0</td><td>21.98</td><td>137.35</td><td>1.38</td><td>0.0</td><td>137184.67</td><td>137344.48</td><td>-0.48</td><td>1.38</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>09:33:37</td><td>&quot;000900&quot;</td><td>&quot;现代投资&quot;</td><td>&quot;买入&quot;</td><td>4.05</td><td>34400.0</td><td>139320.0</td><td>22.29</td><td>0.0</td><td>1.39</td><td>0.0</td><td>-139342.29</td><td>139320.0</td><td>0.0</td><td>1.39</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-11</td><td>09:38:16</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;买入&quot;</td><td>13.51</td><td>10400.0</td><td>140504.0</td><td>22.48</td><td>0.0</td><td>1.41</td><td>0.0</td><td>-140526.48</td><td>140504.0</td><td>0.0</td><td>1.41</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (363, 17)\n",
       "┌──────┬────────────┬──────────┬──────────┬───┬────────────┬───────────┬───────────┬───────────┐\n",
       "│ 券商 ┆ 交易日期   ┆ 交易时间 ┆ 证券代码 ┆ … ┆ 发生金额   ┆ 成交金额2 ┆ 成交金额D ┆ 发生金额D │\n",
       "│ ---  ┆ ---        ┆ ---      ┆ ---      ┆   ┆ ---        ┆ ---       ┆ ---       ┆ ---       │\n",
       "│ str  ┆ date       ┆ time     ┆ str      ┆   ┆ f64        ┆ f64       ┆ f64       ┆ f64       │\n",
       "╞══════╪════════════╪══════════╪══════════╪═══╪════════════╪═══════════╪═══════════╪═══════════╡\n",
       "│ 湘财 ┆ 2022-07-18 ┆ 09:44:52 ┆ 600408   ┆ … ┆ -149955.5  ┆ 149930.0  ┆ 0.0       ┆ 0.0       │\n",
       "│ 湘财 ┆ 2022-07-18 ┆ 09:44:31 ┆ 600648   ┆ … ┆ -150044.49 ┆ 150018.54 ┆ 0.46      ┆ 0.0       │\n",
       "│ 湘财 ┆ 2022-07-18 ┆ 09:43:38 ┆ 600269   ┆ … ┆ -150208.53 ┆ 150183.0  ┆ 0.0       ┆ 0.0       │\n",
       "│ 湘财 ┆ 2022-07-18 ┆ 09:42:51 ┆ 600015   ┆ … ┆ -152125.86 ┆ 152100.0  ┆ 0.0       ┆ 0.0       │\n",
       "│ 湘财 ┆ 2022-07-18 ┆ 09:39:28 ┆ 601992   ┆ … ┆ 138523.74  ┆ 138688.2  ┆ -2.2      ┆ 0.0       │\n",
       "│ …    ┆ …          ┆ …        ┆ …        ┆ … ┆ …          ┆ …         ┆ …         ┆ …         │\n",
       "│ 湘财 ┆ 2022-10-24 ┆ 09:37:27 ┆ 300283   ┆ … ┆ -69720.15  ┆ 69709.02  ┆ -0.02     ┆ 0.83      │\n",
       "│ 湘财 ┆ 2022-10-11 ┆ 09:32:03 ┆ 000900   ┆ … ┆ 132167.48  ┆ 132319.6  ┆ 1.4       ┆ 1.31      │\n",
       "│ 湘财 ┆ 2022-07-18 ┆ 09:38:10 ┆ 002462   ┆ … ┆ 137184.67  ┆ 137344.48 ┆ -0.48     ┆ 1.38      │\n",
       "│ 湘财 ┆ 2022-07-11 ┆ 09:33:37 ┆ 000900   ┆ … ┆ -139342.29 ┆ 139320.0  ┆ 0.0       ┆ 1.39      │\n",
       "│ 湘财 ┆ 2022-07-11 ┆ 09:38:16 ┆ 002462   ┆ … ┆ -140526.48 ┆ 140504.0  ┆ 0.0       ┆ 1.41      │\n",
       "└──────┴────────────┴──────────┴──────────┴───┴────────────┴───────────┴───────────┴───────────┘"
      ]
     },
     "execution_count": 196,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.with_columns(\n",
    "    成交金额2=pl.col(\"成交价格\") * pl.col(\"成交数量\"),\n",
    ").with_columns(\n",
    "    成交金额D=pl.col(\"成交金额\") - pl.col(\"成交金额2\"),\n",
    ").with_columns(\n",
    "    发生金额D=(\n",
    "        pl.col(\"发生金额\")\n",
    "        - (\n",
    "            pl.when(pl.col(\"买卖标志\") == \"买入\")\n",
    "            .then(-pl.col(\"成交金额\"))\n",
    "            .when(pl.col(\"买卖标志\") == \"卖出\")\n",
    "            .then(pl.col(\"成交金额\"))\n",
    "            - pl.col(\"手续费\")\n",
    "            - pl.col(\"印花费\")\n",
    "            - pl.col(\"过户费\")\n",
    "            - pl.col(\"其他费\")\n",
    "        )\n",
    "    ).round(4)\n",
    ").sort(\"发生金额D\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 198,
   "id": "bd9f3bb6-71ad-4344-a0df-f764d5caa256",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.write_parquet(\"stock_trades.parquet\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 199,
   "id": "7b060265-43ea-4def-b725-fe47afdb3557",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.write_csv(\"stock_trades.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 200,
   "id": "8c9740df-238c-4fb5-8d78-ddef8c0d470f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<xlsxwriter.workbook.Workbook at 0x1ec896e4c20>"
      ]
     },
     "execution_count": 200,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.write_excel(\"stock_trades.xlsx\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 201,
   "id": "8fa74210-2289-4400-8a33-e9859faebbf4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><style>\n",
       ".dataframe > thead > tr,\n",
       ".dataframe > tbody > tr {\n",
       "  text-align: right;\n",
       "  white-space: pre-wrap;\n",
       "}\n",
       "</style>\n",
       "<small>shape: (363, 14)</small><table border=\"1\" class=\"dataframe\"><thead><tr><th>券商</th><th>交易日期</th><th>交易时间</th><th>证券代码</th><th>证券名称</th><th>买卖标志</th><th>成交价格</th><th>成交数量</th><th>成交金额</th><th>手续费</th><th>印花费</th><th>过户费</th><th>其他费</th><th>发生金额</th></tr><tr><td>str</td><td>date</td><td>time</td><td>str</td><td>str</td><td>str</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td><td>f64</td></tr></thead><tbody><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:38:10</td><td>&quot;002462&quot;</td><td>&quot;嘉事堂&quot;</td><td>&quot;卖出&quot;</td><td>13.2062</td><td>10400.0</td><td>137344.0</td><td>21.98</td><td>137.35</td><td>1.38</td><td>0.0</td><td>137184.67</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:44:52</td><td>&quot;600408&quot;</td><td>&quot;安泰集团&quot;</td><td>&quot;买入&quot;</td><td>3.19</td><td>47000.0</td><td>149930.0</td><td>23.99</td><td>0.0</td><td>1.51</td><td>0.0</td><td>-149955.5</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:44:31</td><td>&quot;600648&quot;</td><td>&quot;外高桥&quot;</td><td>&quot;买入&quot;</td><td>12.6066</td><td>11900.0</td><td>150019.0</td><td>24.0</td><td>0.0</td><td>1.49</td><td>0.0</td><td>-150044.49</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:43:38</td><td>&quot;600269&quot;</td><td>&quot;赣粤高速&quot;</td><td>&quot;买入&quot;</td><td>3.69</td><td>40700.0</td><td>150183.0</td><td>24.03</td><td>0.0</td><td>1.5</td><td>0.0</td><td>-150208.53</td></tr><tr><td>&quot;湘财&quot;</td><td>2022-07-18</td><td>09:42:51</td><td>&quot;600015&quot;</td><td>&quot;华夏银行&quot;</td><td>&quot;买入&quot;</td><td>5.07</td><td>30000.0</td><td>152100.0</td><td>24.34</td><td>0.0</td><td>1.52</td><td>0.0</td><td>-152125.86</td></tr><tr><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td><td>&hellip;</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-18</td><td>09:46:15</td><td>&quot;300464&quot;</td><td>&quot;星徽股份&quot;</td><td>&quot;卖出&quot;</td><td>5.74</td><td>16100.0</td><td>92414.0</td><td>8.82</td><td>46.21</td><td>0.0</td><td>0.0</td><td>92358.97</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-18</td><td>09:55:41</td><td>&quot;002661&quot;</td><td>&quot;克明食品&quot;</td><td>&quot;买入&quot;</td><td>9.42</td><td>8500.0</td><td>80072.0</td><td>7.64</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-80079.64</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-09</td><td>09:48:02</td><td>&quot;002753&quot;</td><td>&quot;永东股份&quot;</td><td>&quot;买入&quot;</td><td>7.02</td><td>14200.0</td><td>99684.0</td><td>9.51</td><td>0.0</td><td>0.0</td><td>0.0</td><td>-99693.51</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-09</td><td>09:45:18</td><td>&quot;000698&quot;</td><td>&quot;沈阳化工&quot;</td><td>&quot;卖出&quot;</td><td>4.053</td><td>23800.0</td><td>96460.0</td><td>9.2</td><td>48.24</td><td>0.0</td><td>0.0</td><td>96402.56</td></tr><tr><td>&quot;海通两融&quot;</td><td>2023-10-09</td><td>09:44:40</td><td>&quot;605288&quot;</td><td>&quot;凯迪股份&quot;</td><td>&quot;卖出&quot;</td><td>40.838</td><td>2500.0</td><td>102094.0</td><td>9.74</td><td>51.05</td><td>1.0</td><td>0.0</td><td>102032.21</td></tr></tbody></table></div>"
      ],
      "text/plain": [
       "shape: (363, 14)\n",
       "┌──────────┬────────────┬──────────┬──────────┬───┬────────┬────────┬────────┬────────────┐\n",
       "│ 券商     ┆ 交易日期   ┆ 交易时间 ┆ 证券代码 ┆ … ┆ 印花费 ┆ 过户费 ┆ 其他费 ┆ 发生金额   │\n",
       "│ ---      ┆ ---        ┆ ---      ┆ ---      ┆   ┆ ---    ┆ ---    ┆ ---    ┆ ---        │\n",
       "│ str      ┆ date       ┆ time     ┆ str      ┆   ┆ f64    ┆ f64    ┆ f64    ┆ f64        │\n",
       "╞══════════╪════════════╪══════════╪══════════╪═══╪════════╪════════╪════════╪════════════╡\n",
       "│ 湘财     ┆ 2022-07-18 ┆ 09:38:10 ┆ 002462   ┆ … ┆ 137.35 ┆ 1.38   ┆ 0.0    ┆ 137184.67  │\n",
       "│ 湘财     ┆ 2022-07-18 ┆ 09:44:52 ┆ 600408   ┆ … ┆ 0.0    ┆ 1.51   ┆ 0.0    ┆ -149955.5  │\n",
       "│ 湘财     ┆ 2022-07-18 ┆ 09:44:31 ┆ 600648   ┆ … ┆ 0.0    ┆ 1.49   ┆ 0.0    ┆ -150044.49 │\n",
       "│ 湘财     ┆ 2022-07-18 ┆ 09:43:38 ┆ 600269   ┆ … ┆ 0.0    ┆ 1.5    ┆ 0.0    ┆ -150208.53 │\n",
       "│ 湘财     ┆ 2022-07-18 ┆ 09:42:51 ┆ 600015   ┆ … ┆ 0.0    ┆ 1.52   ┆ 0.0    ┆ -152125.86 │\n",
       "│ …        ┆ …          ┆ …        ┆ …        ┆ … ┆ …      ┆ …      ┆ …      ┆ …          │\n",
       "│ 海通两融 ┆ 2023-10-18 ┆ 09:46:15 ┆ 300464   ┆ … ┆ 46.21  ┆ 0.0    ┆ 0.0    ┆ 92358.97   │\n",
       "│ 海通两融 ┆ 2023-10-18 ┆ 09:55:41 ┆ 002661   ┆ … ┆ 0.0    ┆ 0.0    ┆ 0.0    ┆ -80079.64  │\n",
       "│ 海通两融 ┆ 2023-10-09 ┆ 09:48:02 ┆ 002753   ┆ … ┆ 0.0    ┆ 0.0    ┆ 0.0    ┆ -99693.51  │\n",
       "│ 海通两融 ┆ 2023-10-09 ┆ 09:45:18 ┆ 000698   ┆ … ┆ 48.24  ┆ 0.0    ┆ 0.0    ┆ 96402.56   │\n",
       "│ 海通两融 ┆ 2023-10-09 ┆ 09:44:40 ┆ 605288   ┆ … ┆ 51.05  ┆ 1.0    ┆ 0.0    ┆ 102032.21  │\n",
       "└──────────┴────────────┴──────────┴──────────┴───┴────────┴────────┴────────┴────────────┘"
      ]
     },
     "execution_count": 201,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pl.read_parquet(\"stock_trades.parquet\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b1c2765d-4d4d-436a-be4a-afbc57e14aca",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
